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 you are stacking plates. Each time you get an opening bracket, you put a plate on the stack. When you get a closing bracket, you remove the top plate and check if it matches the type of bracket.
Stack (top at right): []
Expression: ( [ { } ] )
ā start reading from left to right