bits consists of zeros and ones, and you get a number fixes. You may turn at most fixes zeros into ones.
Return the greatest length of a contiguous stretch of ones you can obtain.bits=[0, 1, 1, 0, 0, 1, 0, 1], fixes=2 → 5
Fix the zeros at positions 3 and 4: positions 1 to 5 become [1, 1, 1, 1, 1], length 5. No choice of two zeros does better.
bits=[1, 0, 1], fixes=0 → 1
Nothing may be fixed, so the longest run is a single 1.
bits=[0, 0, 1, 0], fixes=4 → 4
There are enough fixes for every zero, so the whole tape becomes ones.
bits=[0, 1, 1, 0, 0, 1, 0, 1], fixes=2
5
Run checks the first 3 tests in your browser. Submit checks all 80 tests on the server, hidden ones included.