A row of n bars stands side by side. Every bar is 1 unit wide, and height[i] is the height of bar i. After it rains, water collects in the gaps between taller bars.
Return the total units of water that stay trapped.
Examples
Example 1:
Input: height = [3,0,2,0,4]
Output: 7
Explanation: Water fills up to height 3 over the gaps: 3 units over index 1, 1 unit over index 2, and 3 units over index 3. Total = 3 + 1 + 3 = 7.
Example 2:
Input: height = [2,0,2]
Output: 2
Explanation: The gap between the two bars holds 2 units.
Example 3:
Input: height = [1,2,3,4]
Output: 0
Explanation: The bars only go up, so no water stays.