Loading...
Loading...
Loading...
A sensor sends 1 for a good reading and 0 for a failed one. You may repair at most k failed readings, turning each into a 1. Find the longest run of consecutive 1s after repairs.
Example 1
Input
11 2 1 1 1 0 0 0 1 1 1 1 0
Output
6
Repair two zeros for a run of 6.
Example 2
Input
3 0 0 0 0
Output
0
Try the problem first. Open one hint at a time.
A window is allowed when it holds at most k zeros.
Grow the right end, and when the zeros exceed k, move the left end until they do not.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor