Trapping Rain Water

Given n non-negative integers where height[i] is the elevation at index i and every bar has width 1, return how many units of rain water remain trapped…

Given `n` non-negative integers where `height[i]` is the elevation at index `i` and every bar has width 1, return how many units of rain water remain trapped between the bars after raining.

- `1 <= height.length <= 2 * 10^4` - `0 <= height[i] <= 10^5` - The interactive visualizer accepts at most 12 values between 0 and 10,000; other statement-valid inputs are execution-only.

Example 1: input height = [0,1,0,2,1,0,1,3,2,1,2,1]; output 6. The bounded gaps collectively hold 6 units of water.

Example 2: input height = [4,2,0,3,2,5]; output 9. Summing the water above the interior bars gives 9.

Category: Two Pointers. Topic: two-pointers. Difficulty: Hard. Patterns: dynamic-programming, two-pointers.