Pattern Recognition Drill
Medium Stacks & Queues
The Problem
Check if a string of brackets is balanced: ()[]{}
What approach would you use?
Think about it before scrolling down.
Push open brackets, pop on close brackets. Top must match. Stack empty at end → balanced. O(n).
Common Trap
Counter-based approach only works for single bracket type. Multiple types require a stack.