Ones After K Flips
bits contains only 0s and 1s. Return the length of the longest contiguous run of 1s you can get by flipping at most k zeros to 1.
Examples
EXAMPLE WALKTHROUGHclassic
A guided view of the published example, not a trace of your code.
INPUT
[[1,1,1,0,0,0,1,1,1,1,0],2]TASKones_after_k_flips()
EXPECTED OUTPUT
6Start with the input values shown in this example.
Example 1 of 3
Input: bits = [1,1,1,0,0,0,1,1,1,1,0], k = 2
Output: 6
Explanation: classic
Input: bits = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], k = 3
Output: 10
Explanation: longer
Input: bits = [0,0,0], k = 0
Output: 0
Explanation: no flips
Hint 1
Keep a window with at most k zeros; shrink from the left when it has too many.