We use analytics and advertising cookies to understand how the site is used and whether our ads on Facebook and Instagram work. They are set only if you accept. See our Privacy Policy for details.
A stack is the right answer whenever the most recently seen item is the one you need next: matching parentheses, evaluating postfix expressions, or walking a browser history. The tell is nesting or reversal in the problem statement. It is also the substrate for the monotonic-stack pattern, which is where stacks get genuinely hard.
Balanced brackets, nested structures, undo/back semantics, or expression evaluation.
12 problems. Each one runs in an in-browser editor against real test cases, with hints and a worked solution.
The patterns cheat sheet covers all of these in one page - what each one looks like in a problem statement, and the template that follows.