Loading...
Loading...
Loading...
A list of daily gains and losses is given. Print the largest sum of any non-empty run of neighbouring days. All days may be losses, and then the answer is the least bad single day. The starter holds a program with a bug. Find it and fix it.
Example
Input
5 -2 3 -1 4 -6
Output
6
The run 3 -1 4 adds up to 6.
Try the problem first. Open one hint at a time.
Track the best sum of a run that ends at the current day.
That run either starts again at this day or extends the one before it.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor