For each position, find the maximum height to its left and right. Water at that position is min(leftMax, rightMax) - height[i].
Finding the maximum on each side takes per position. With positions, that's total.
For , you'd have operations. Too slow.