1047. Remove All Adjacent Duplicates In String

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1047

class Solution:
    def removeDuplicates(self, s: str) -> str:
        stk = []
        for c in s:
            if stk and stk[-1] == c:
                stk.pop()
            else:
                stk.append(c)
        return ''.join(stk)