255. Max Consecutive Ones II
MediumSliding Window
Given a binary array `nums`, return the maximum number of consecutive `1`'s in the array if you can flip at most one `0`.
Examples
Input: [1,0,1,1,0]
Output: 4
Explanation: Flipping the first 0 gives 1,1,1,1 — four consecutive ones.
Constraints
- 1 <= nums.length <= 10^5
- nums[i] is either 0 or 1.
Loading...
Run checks all cases above. Submit evaluates all test cases.