Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save EfrainReyes/c74ba20672eec5c1fc58121329c6f4a1 to your computer and use it in GitHub Desktop.
Save EfrainReyes/c74ba20672eec5c1fc58121329c6f4a1 to your computer and use it in GitHub Desktop.
1047. Remove All Adjacent Duplicates In String
class Solution:
def removeDuplicates(self, s: str) -> str:
stack = []
for char in s:
if stack and stack[-1] == char:
stack.pop()
else:
stack.append(char)
return "".join(stack)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment