Removes all adjacent duplicate characters repeatedly using a stack; O(n) time and space.
## What is it?
Remove all adjacent duplicate characters from a string repeatedly until no adjacent duplicates remain. This is a classic stack-based string cleaning problem.
## How it works
**Stack approach:**
- Iterate through each character in the string
- If the stack is not empty and the top of the stack equals the current character → pop (remove the pair)
- Otherwise → push the current character
- At the end, the stack contains the result string
## When to use
- String simplification and cleaning
- Undo-style problems where matching pairs cancel out
- As a building block for more complex stack problems
## Key Points
- O(n) time — each character is pushed and popped at most once
- O(n) space — stack can hold up to n characters
- The result is the characters left in the stack after processing
- Extension: "Remove k adjacent duplicates" uses a stack of (char, count) pairs