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
Similar Kata:
Stats:
Created | Feb 7, 2014 |
Published | Feb 7, 2014 |
Warriors Trained | 1661 |
Total Skips | 96 |
Total Code Submissions | 3769 |
Total Times Completed | 918 |
JavaScript Completions | 642 |
Java Completions | 244 |
Python Completions | 46 |
Total Stars | 44 |
% of votes with a positive feedback rating | 89% of 175 |
Total "Very Satisfied" Votes | 142 |
Total "Somewhat Satisfied" Votes | 27 |
Total "Not Satisfied" Votes | 6 |
Total Rank Assessments | 9 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |