Max Consecutive Ones III

Given a binary array nums and an integer k, the task is to find the maximum number of consecutive 1's in the array if you are allowed to flip at most k 0's.

Constraints

  • 1 <= nums.length <= 10^5
  • nums[i] is either 0 or 1
  • 0 <= k <= nums.length
Saving… · 3 lines
class Solution:
def maxConsecutiveOnesIII(self, nums: List[int], k: int) -> int:
pass
Console

Click Run to execute sample tests.