Difficulty
Easy
Language
Python
Solution 1 - Stack
Push chars; pop when top equals current.
""" 1047.1 - Remove All Adjacent Duplicates In String - Solution 1 - Stack """
class Solution:
def removeDuplicates(self, s: str) -> str:
st = []
for c in s:
if st and st[-1] == c:
st.pop()
else:
st.append(c)
return "".join(st)