less than 1 minute read

You are given a string s containing 1s and 0s. Given that you can flip at most one "0", return the length of the longest contiguous substring of 1s.

Constraints

  • n ≤ 100,000 where n is the length of s.

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".

Solution

Leave a comment