You get an array height of non-negative integers. Each value is a bar one unit wide, and the bars stand side by side in array order. Rain fills every dip that has a taller bar on both sides; anything that would rise above the lower of those two walls runs off. Return the total number of water units left standing.
The water above bar i is the smaller of the tallest bar at or before i and the tallest bar at or after i, minus height[i]. Both ranges include bar i itself, so a bar never holds a negative amount. The answer is that value summed over every bar. An empty array, a single bar, or a row with no dip at all holds 0; equal walls on both sides count as walls.