Description
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.
Example 1:
| |
Example 2:
| |
Constraints:
1 <= nums.length <= 105nums[i]is either0or1.0 <= k <= nums.length
Solutions
The approach for this problem is to use a sliding window, then look for the longest subarray that is 1 in length. Also, consider that when there are 0s, they can be flipped to 1s, which means that if the number of 0s is within k, they can be counted in the longest subarray of 1s.
| |
