You have an elevation profile described by n non-negative integers. Each bar is 1 unit wide. Determine the total amount of rainwater retained by the profile after rainfall.
Example 1:
Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6
Explanation:
The bars hold 6 units of water in the spaces between higher elevations. The amounts above each column are 0, 0, 1, 0, 1, 2, 1, 0, 0, 1, 0, 0, which sum to 6.
height = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1]6
The array gives the height of each one-unit-wide bar from left to right.
Example 2:
Input: height = [4,2,0,3,2,5]
Output: 9
n == height.length1 <= n <= 2 * 10^40 <= height[i] <= 10^5height = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1]6
The array gives the height of each one-unit-wide bar from left to right.