class Solution: def makeFancyString(self, s: str) -> str: for c in set(s): while c*3 in s: s = s.replace(c*3, c*2) return s