Workspace Matching Stack
0d
Problem-solving patterns

Matching Stack

Use the latest unfinished opener to interpret the next closer.

Recognition signal

The problem has nesting, undo order or deferred operations.

Method

Push an opener and pop only after verifying a matching closer.

Worked example

In “([)]”, the first closer meets [ on top, so the nesting fails.

Common mistake

Equal counts do not prove valid nesting.