Max Consecutive Ones (with one flip) — C# Coding Problem
Difficulty: easy | Category: sliding-window
Problem Description
Given a binary array `nums`, return the maximum number of consecutive `1`s in the array if you can flip at most one `0`. **Constraints:** `1 <= nums.length <= 10^5`
Examples
Example 1
Input: nums = [1,0,1,1,0]
Output: 4
Explanation: Flip the first 0 to get [1,1,1,1,0] or flip the second to get [1,0,1,1,1].
Example 2
Input: nums = [1,0,1,1,0,1]
Output: 4