Description

Figure out the difference between the local min and the min of the two local maximums
42. Trapping Rain Water-1783372868826.webp

When you are trying to find the water related problems :: depth = min(local_max) - current_height
When dealing with two pointer solutions with water :: always move the lower one

Runtime

O(3n)

Pseudocode

Compute all the max heights from left, then from right
count = 0
for each heights
	count += min(left[i], right[i]) - height
return count