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 calculate the biggest flat area you can make with those books.
Histogram bars: heights = [2, 1, 5, 6, 2, 3] Stack stores indices of bars in increasing height order. Initial: Index: 0 1 2 3 4 5 Height:2 1 5 6 2 3 Stack: []
