
advanced
13 min read
Largest Rectangle in Histogram
The hard part is rarely choosing a rectangle height. It is proving how far that height can extend.
View solutionMaintain monotonic candidates for next-greater, histogram, and sliding-window problems.
Problems
Practice problems that share this primary solution pattern and compare the clues that reveal it.

The hard part is rarely choosing a rectangle height. It is proving how far that height can extend.
View solution
Turn each matrix row into a histogram, solve that histogram with a monotonic stack, and keep only the state that can still affect future rows.
View solution