5 kyu

Maximum Contiguous Sum

642 of 918thibaultCha

Description:

Given an unsorted array of integer values, find the maximum positive sum of any contiguous range within the array.

An array containing only negative values can return 0. Your solution should be efficient enough to not throw a timeout exception.

Example:

maxContiguousSum([3, -4, 8, 7, -10, 19, -3]); // returns 24
maxContiguousSum([-8, -10, -12, -2, -3, 5]); // returns 5

Visual example:

[3, -4, 8, 7, -10, 19, -3]
       |_____________|
             ||
             \/
             24
Arrays
Algorithms

Stats:

CreatedFeb 7, 2014
PublishedFeb 7, 2014
Warriors Trained1661
Total Skips96
Total Code Submissions3769
Total Times Completed918
JavaScript Completions642
Java Completions244
Python Completions46
Total Stars44
% of votes with a positive feedback rating89% of 175
Total "Very Satisfied" Votes142
Total "Somewhat Satisfied" Votes27
Total "Not Satisfied" Votes6
Total Rank Assessments9
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • thibaultCha Avatar
  • jhoffner Avatar
  • sazzadshopno Avatar
  • dfhwze Avatar
  • luxcem Avatar
Ad