Given a binary array nums, return the maximum number of consecutive 111’s in the array if you are allowed to flip at most one 000.
nums
Constraints:
1≤1 \leq1≤ nums.length ≤105\leq 10^5≤105
nums.length
nums[i] is either 000 or 111.
nums[i]
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Max Consecutive Ones II
For the input [0], what is the maximum number of consecutive 111's after flipping at most one 000?
[0]
000
111
222
The input length is invalid
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Implement your solution in the following coding playground.