Concept Flow - Trapping Rain Water Using Stack
Start with empty stack
Iterate over height array
While stack not empty and current height > height at stack top
Pop top
Calculate trapped water
Push current index to stack
Repeat until end
Return total trapped water
We scan the height array, using a stack to keep indices of bars. When we find a bar taller than the top of the stack, we pop and calculate trapped water between bars.
