2025-08-02 07:38:33 +0000 UTC
Remove All Adjacent Duplicates In String
Categories:
Links
Code
class Solution:
def removeDuplicates(self, s: str) -> str:
stack = []
for char in s:
if stack and char == stack[-1]:
stack.pop()
else:
stack.append(char)
return "".join(stack)