Loading...
Loading...
Loading...
A cashier's system stores the number of orders for n hours. Print the total number of orders for every stretch of k hours in a row, from the first stretch to the last.
Example
Input
5 2 3 1 4 1 5
Output
4 5 5 6
The stretches are 3+1, 1+4, 4+1 and 1+5.
Try the problem first. Open one hint at a time.
There are n - k + 1 stretches.
Build a list and append the running total after each move.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor