2
def minFlipsMonoIncr(self, s: str) -> int:13
) # since we will start with 11...11 then every zero in s will be on the right side of the border15
# for each i imagine that we have the borderline at i index any index >= i will be 1 and index < i will be 0.16
# i = 0, n = 5 -> 1111117
# i = 1, n = 5 -> 0111119
for i in range(n + 1):20
# the number of flip will be equal number of 1 on the left side of the border + number of zero on the right side of the border23
# comparing with 00111 : i = 2, one_left = 0, zero_right = 1, then we have to do 0 + 1 flip in this i24
min_flip = min(min_flip, one_left + zero_right)26
# edge case for i = n or all zero (00...00)29
# reduce count of zero_right when 0 is moving to the 0-zone or left side of border34
1 # increase one on the left side when we move 1 into the left side