1047. Remove All Adjacent Duplicates In String
On This Page
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)