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 trapped water
Add trapped water to total
Push current index to stack
Repeat until end of array
Return total trapped water
We use a stack to keep indexes of bars. When current bar is higher than top of stack, we pop and calculate trapped water between bars.
