Tap here to switch tabs
Problem
Submissions

Problem: Max Consecutive Ones II

Max Consecutive Ones II asks for the longest run of consecutive ones in a binary array when you may flip at most one zero to one.

Statement

Given a binary array nums, return the maximum number of consecutive 11’s in the array if you are allowed to flip at most one 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • nums[i] is either 00 or 11.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Max Consecutive Ones II

Max Consecutive Ones II asks for the longest run of consecutive ones in a binary array when you may flip at most one zero to one.

Statement

Given a binary array nums, return the maximum number of consecutive 11’s in the array if you are allowed to flip at most one 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • nums[i] is either 00 or 11.