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
Update max area
Repeat until all bars processed
Pop remaining bars and calculate areas
Return max area
We scan bars left to right, pushing indices of increasing heights. When a lower bar appears, we pop from stack to calculate areas with popped bars as smallest height, updating max area.
