Nesting
Parentheses and path simplification are pure stack discipline: last unmatched opener must match the next closer.
Lesson
LIFO structure for nesting, next-greater, and parsing.
Loading solution…
Parentheses and path simplification are pure stack discipline: last unmatched opener must match the next closer.
Keep indices in increasing/decreasing value order. When the order breaks, pop and resolve answers for those indices.
Valid Parentheses lesson visualizes push/pop against the character array.
Showing 24 of the related problems in the 1000-question bank.
Valid Parentheses
Stack
Longest Valid Parentheses
Stack / DP
Trapping Rain Water
Two Pointers
Largest Rectangle in Histogram
Monotonic Stack
Maximal Rectangle
Stack / DP
Binary Tree Inorder Traversal
Tree
Min Stack
Design
Decode String
Stack
Valid Parenthesis String
Greedy
Daily Temperatures
Monotonic Stack
Car Fleet
Stack
Make The String Great — Practice 23
Stack
Online Stock Span — Practice 25
Stack
Baseball Game — Practice 28
Stack
Backspace String Compare — Practice 30
Stack
Sum of Subarray Minimums — Practice 32
Stack
Remove Outermost Parentheses — Practice 35
Stack
Asteroid Collision — Practice 37
Stack
Remove Duplicate Letters — Practice 39
Stack
Make The String Great — Practice 42
Stack
Online Stock Span — Practice 44
Stack
Baseball Game — Practice 47
Stack
Backspace String Compare — Practice 49
Stack
Sum of Subarray Minimums — Practice 51
Stack
Got the lesson?
Mark Stack & Monotonic Stack as understood when the ideas stick.