Created
November 10, 2022 01:05
-
-
Save EfrainReyes/c74ba20672eec5c1fc58121329c6f4a1 to your computer and use it in GitHub Desktop.
1047. Remove All Adjacent Duplicates In String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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