algorithm · Level 3 · 35 min
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Imagine rain falling on the bars; water is trapped between bars when there are higher bars on both sides.
height (array of non-negative integers).- `n == height.length` - `1 <= n <= 2 * 10^4` - `0 <= height[i] <= 10^5`
Return the total trapped water (integer).