Hard · Two pointers
Trapping Rain Water
You are given a list of bar heights, each bar one unit wide, standing side by side. Rain falls and pools between the bars. Return how many units of water are held.
- Heights are whole numbers, zero or more.
- Water cannot be held at either end.
- Fewer than three bars hold nothing.
heights = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] → 6Record your take