Skip to content

Latest commit

 

History

History
14 lines (11 loc) · 525 Bytes

File metadata and controls

14 lines (11 loc) · 525 Bytes

Problem 11: Binary Maximal Gap (Max Consecutive Ones III)

Problem Statement

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.

Input Format

  • A binary array nums.
  • An integer k.

Example

Input: nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0], k = 2
Output: 6
Explanation: [1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1] (indices 5-10 after flipping two 0s).

(Wait, actually flipping 0s at index 5, 10 gives length 6).