Max Consecutive Ones III
mediumFind the longest subarray of 1s after flipping at most k zeros
Max Consecutive Ones III
Key Insight
Maintain window with at most k zeros. Shrink left when zero count exceeds k
Step 1Start Window
All onesZeros: 0, k: 2
L
R
1
01
11
20
30
40
51
61
71
81
90
10[———]window
Begin expanding. First three elements are all ones.
1 / 5