Mental Model
We use a stack to keep track of bars that are not yet processed for largest rectangle. When we find a bar shorter than the top of the stack, we calculate areas for bars taller than it.
Analogy: Imagine stacking books by height. When a shorter book arrives, you remove taller books from the stack to find the biggest flat surface you can make with those books.
Histogram bars: 2 1 5 6 2 3 Stack stores indices of bars in increasing height order. Example: Heights: 2 -> 1 -> 5 -> 6 -> 2 -> 3 -> null Stack: bottom [ ] top (stores indices)
