right0
to the count of 0
s in the entire string.left1
to 0, representing the count of 1
s in the left window.minFlips
to right0
, as the initial number of flips needed when the left window is empty.c
in the string s
:
a. If c
is 0
, decrement right0
by 1.
b. If c
is 1
, increment left1
by 1.minFlips
to the minimum of minFlips
and left1 + right0
.minFlips
as the result.