Longest 1s After One Flip
You are given a string s
containing 1
s and 0
s. Given that you can flip at most one "0"
, return the length of the longest contiguous substring of 1
s.
Constraints
n ≤ 100,000
wheren
is the length ofs
.
https://binarysearch.com/problems/Longest-1s-After-One-Flip
Examples
Example 1
Input
- s =
10110
Output
- answer =
4
Explanation
If we flip the first zero then we get "11110"
.
Leave a comment