Concept Flow - Largest Rectangle in Histogram Using Stack
Start with empty stack
Iterate over bars
If stack empty or current bar taller
Push index
Calculate area with popped bar
After iteration, pop remaining bars
Calculate max area
Done
We use a stack to keep indexes of bars in increasing height order. When a lower bar appears, we pop from stack and calculate area with popped bar as smallest height. After processing all bars, we pop remaining bars to find max area.
