1004. Max Consecutive Ones III
Practice Max Consecutive Ones III for free on NudgeCode: Medium, Sliding Window pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
nums is a binary array. You may flip at most k zeros into ones. Return the length of the longest run of consecutive 1s you can get.
Example
nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2 -> 6
nums = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], k = 3 -> 10
Constraints
- 1 <= nums.length <= 10^5
- nums[i] is 0 or 1
- 0 <= k <= nums.length