319. Max Consecutive Ones III
MediumSliding Window
Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.
Examples
Input: [1,1,1,0,0,0,1,1,1,1,0] 2
Output: 6
Explanation: Flip zeros at indices 5 and 10 to get 6 consecutive ones.
Constraints
- 1 <= nums.length <= 10^5
- nums[i] is either 0 or 1.
- 0 <= k <= nums.length
Loading...
Run checks all cases above. Submit evaluates all test cases.