2025-08-21 11:57:54 +0000 UTC
Minimum String Length After Removing Substrings
Categories:
Links
Code
class Solution:
def minLength(self, s: str) -> int:
while "AB" in s or "CD" in s:
s = s.replace("AB", "").replace("CD", "")
return len(s)