1957. Delete Characters to Make Fancy String

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1957

class Solution:
    def makeFancyString(self, s: str) -> str:
        res = []
        for c in s:
            if len(res) > 1 and res[-1] == res[-2] == c:
                continue
            res.append(c)
        return ''.join(res)