Max Consecutive Ones With Flips
nums holds only 0s and 1s. You may flip at most k of the 0s into 1s. Return the length of the longest unbroken run of 1s you can create.
Example 1
nums [1,1,1,0,0,0,1,1,1,1,0]
k 2
returns 6
Flip the 0s at indices 5 and 10: indices 5 to 10 are all 1s, a run of 6.
Constraints
1 <= len(nums) <= 40- Each item is 0 or 1.
0 <= k <= len(nums)
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.