Concept Flow - Largest Rectangle in Histogram Using Stack
Start with empty stack
Iterate over histogram bars
While stack not empty and current bar height < height at stack top
Pop from stack
Calculate area with popped bar as smallest
Update max area if needed
Push current bar index to stack
After iteration, pop remaining bars and calculate area
Return max area
We use a stack to keep indices of bars in ascending height order. When a lower bar appears, we pop from stack and calculate areas with popped bars as smallest height, updating max area.
