Trapping Rain Water - Two Pointer Approach

Water at position ii equals min(maxLeft,maxRight)height[i]\min(maxLeft, maxRight) - height[i]. Instead of precomputing arrays, use two pointers with running maximums.

1.1. Track leftMax and rightMax as you go.

2.2. If leftMax < rightMax, process left pointer. Water is bounded by leftMax.

3.3. Otherwise process right pointer. Water is bounded by rightMax.

4.4. The smaller of the two maxes determines the water level at that position.