DDSA Solutions

Stack

40 problems · 31 with full explanations

7 Easy15 Medium4 Hard
Stacks support LIFO (last-in, first-out) operations in O(1). Key patterns: balanced parentheses, next greater element (monotonic stack), function call simulation, and undo/redo. A monotonic stack maintains a strictly increasing or decreasing order to answer range queries efficiently.

How to practice

To practice Stack problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the stack pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.

Open the full study guide →

Start here (Easy + explained)

All Stack problems