Concept Flow - Largest Rectangle in Histogram Using Stack
Start with empty stack
Iterate over bars
While current bar < top of stack bar
Pop from stack and calculate area
Update max area if needed
Push current bar index to stack
Repeat until all bars processed
Pop remaining bars and calculate area
Return max area
We scan bars left to right, using a stack to keep indexes of bars in ascending height order. When a lower bar appears, we pop taller bars to calculate areas, updating max area.
