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: you put a plate on top for each opening bracket, and when you see a closing bracket, you remove the top plate to see if it matches.
Stack (top at right): []
Expression: ( [ { } ] )
Initial stack is empty: []
We push opening brackets and pop when matching closing bracket appears.