Stack & Queue

Use a stack to remember the most recent unfinished thing, or a queue to handle things in arrival order. The tell is matching, nesting, or finding the next greater item, as in Valid Parentheses and Daily Temperatures. It often replaces a repeated rescan with one pass.

28 problems · 6 with a video · 3 to practice in an AI round

Stack & Queue problems
#ProblemDifficultyVideoAI round
1Valid ParenthesesEasyAI round
2Largest Rectangle in HistogramHard—
3Daily TemperaturesMediumAI round
4Decode StringMediumAI round
5Maximal RectangleHard—
6Remove K DigitsMedium—
7Next Greater Element IEasy
8First Unique Character in a StringEasy
9Asteroid CollisionMedium—
10Sum of Subarray MinimumsMedium—
11Remove Duplicate LettersMedium—
12Next Greater Element IIMedium—
13Evaluate Reverse Polish NotationMedium—
14132 PatternMedium—
15Maximum Sum Circular SubarrayMedium—
16Minimum Remove to Make Valid ParenthesesMedium—
17Remove All Adjacent Duplicates In StringEasy—
18Basic CalculatorHard—
19Simplify PathMedium—
20Basic Calculator IIMedium—
21Remove All Adjacent Duplicates in String IIMedium—
22Maximum Binary TreeMedium
23Car FleetMedium—
24Find the Winner of the Circular GameMedium—
25Remove Outermost ParenthesesEasy—
26Verify Preorder Sequence in Binary Search TreeMedium—
27Basic Calculator IIIHard—
28Minimum Number of Visited Cells in a GridVery hard—

Practice in an AI round

Three of these are AI rounds: 30 minutes, an AI agent beside your code, then a scored report.

Practice Valid Parentheses in an AI round