Check whether a string like "{[()]}" has balanced brackets. Which data structure fits?
- Stack
- Queue
- Hash set
- Heap
Show answer
Answer: A. Stack
Clue: nesting, where the most recent opener must close first (last in, first out). Push openers; on a closer, the top of the stack must be its match. The stack must be empty at the end.