Blue Ocean: Longest Continuous Ones of a String contains 0 or 1
Given a string consisted of only 0 or 1, and a number N.
Read full article from Blue Ocean: Longest Continuous Ones of a String contains 0 or 1
Given a string consisted of only 0 or 1, and a number N.
We have N times to flip 0 to 1 in array. Find the longest continuous 1 after we flipped the N zero elements. Rotation is allowed.
For example, 100100111000, n=2, the best flip is 100111111000, return 6
10001101101, n=2, the best flip is 10001111111, return 8(rotation is allowed)
The following algorithm is more like a inch worm walking on a line, it tries to go forward as it can, then shrink from the tail, then move forward again.
Read full article from Blue Ocean: Longest Continuous Ones of a String contains 0 or 1