Mental Model
We use a stack to keep track of bars in increasing height order to find the largest rectangle efficiently.
Analogy: Imagine stacking books by height on a shelf. When a shorter book comes, you remove taller books to measure the largest flat space you can get between them.
Histogram bars: heights = [2, 1, 5, 6, 2, 3] Index: 0 1 2 3 4 5 Bars: 2 -> 1 -> 5 -> 6 -> 2 -> 3 Stack: empty initially We push indices of bars with increasing heights to stack.
