Loading...
Loading...
Loading...
Given the sales of each day, find the biggest total over any k days in a row. Print that total.
Example
Input
6 3 2 1 5 1 3 2
Output
9
The stretch 5 + 1 + 3 = 9 is the best.
Try the problem first. Open one hint at a time.
Add the first k values once. Then move the window one day at a time: add the new day and subtract the one that left.
Keep the biggest total you have seen so far.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor