1653. Minimum Deletions to Make String Balanced
On This Page
class Solution:
def minimumDeletions(self, s: str) -> int:
lb, ra = 0, s.count('a')
res = len(s)
for c in s:
ra -= c == 'a'
res = min(res, lb + ra)
lb += c == 'b'
return res