Loading...
Loading...
Loading...
A server log has n days: 1 means the service was up and 0 means it was down. You may mark at most k down days as repaired. Print the length of the longest run of up days after the repairs.
Example
Input
10 2 1 1 0 0 1 1 1 0 1 1
Output
7
Repairing two of the three down days gives a run of 7 up days.
Try the problem first. Open one hint at a time.
Count the zeros inside the current run.
While there are more than k zeros, move the left end and reduce the count if you pass a zero.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor