2025-08-02 10:38:33 +0300 MSK
Remove All Adjacent Duplicates In String
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)