##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Stacks are last in, first out. Learn monotonic stacks for next greater element and histogram problems.
Classic bracket matching problem that teaches basic stack operations for finding the longest valid bracket subsequence.
Array-backed
Teaches bracket balance counting using stack-based thinking to determine minimum moves for a regular bracket sequence.
Reinforces greedy stack approach for extracting regular bracket subsequences of specified length.
Teaches using stacks to characterize bracket sequences and count valid concatenations via sequence signatures.
Excellent problem combining stack with greedy strategy to build lexicographically minimal strings.
Classic stack application for finding longest valid bracket sequences with counting. Teaches advanced stack indexing.
Fundamental monotonic stack problem for finding the range where each element is minimum. Essential optimization pattern.
Combines monotonic stack with LIS concepts. Teaches maintaining multiple stacks for optimal color assignment.
Teaches simulation with stacks for prefix removal operations, combining pattern recognition with bracket matching.
Constructive problem requiring generation of multiple distinct regular bracket sequences.
Advanced monotonic stack optimization for DP transitions. Efficiently find range maximums during state computation.
Advanced problem involving stack operation queries across time. Teaches persistent data structure concepts.
Perfect introduction to stack data structure; teaches the fundamental LIFO principle for matching paired elements.
Most popular monotonic stack problem; combines next greater element with distance calculation.
The gold standard for monotonic stack mastery; requires finding both previous and next smaller elements.
Can be solved with two pointers, DP, or monotonic stack. The stack solution processes elements layer by layer.
Teaches contribution technique with monotonic stacks. Each element contributes to multiple subarrays based on boundaries.
Teaches greedy monotonic stack for lexicographical ordering; combines frequency counting with stack manipulation.
Non-obvious monotonic stack application requiring reverse traversal; teaches maintaining candidates while searching.
Requires finding the second greater element using two stacks; advanced extension of classic next greater pattern.