2380. Time Needed to Rearrange a Binary String
On This Page
class Solution:
def secondsToRemoveOccurrences(self, s: str) -> int:
res = cnt = 0
for c in s:
if c == '0':
cnt += 1
elif cnt:
res = max(res + 1, cnt)
return res