Best Streak (Arrays & Lists)

Find the contiguous, non-empty stretch of the list with the largest sum and print that sum.

Input: n (1 to 1000), then n integers between -10^4 and 10^4.

Output: One integer.

Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Kadane: the best stretch ending here either extends the one ending just before, or starts fresh here.

More Arrays & Lists practice