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 from stack
Calculate distance and bounded height
Add trapped water
Push current index to stack
Move to next index
End when all bars processed
Return total trapped water
We scan bars left to right, using a stack to find boundaries that trap water. When current bar is taller than stack top, we pop and calculate trapped water between boundaries.
