Mental Model
We use a stack to keep track of opening brackets and check if each closing bracket matches the last opened one.
Analogy: Imagine stacking plates; each time you see an opening bracket, you put a plate on the stack, and each closing bracket means you remove the top plate and check if it matches.
Stack (top at right): []
Expression: ( [ { } ] )
ā Start scanning from left to right