nums is an array of 0s and 1s. You may change up to k of its 0s into 1s (any of them, or none).
Return the length of the longest run of consecutive 1s the array can have after your changes.
Change the 0s at positions 5 and 7 (counting from 0). Positions 5 to 10 then hold six 1s in a row. Every stretch of seven numbers holds at least three 0s, so 6 is the best.
With no changes allowed, the answer is the longest run already there: the three 1s in the middle.
k may be larger than the number of 0s. Here all three can change, and the whole array becomes 1s.
Constraints
1 <= nums.length <= 10⁵nums[i] is 0 or 1.0 <= k <= nums.lengthRephrase it: find the longest stretch of the array that holds at most k zeros. Changing those zeros turns the whole stretch into 1s.
6