Optimal Algorithmic Approach
Two-pointer: always advance the smaller boundary side.
Core Invariants & Edge Cases
- Water at i = min(maxLeft[i], maxRight[i]) - height[i]
- Two-pointer O(1) space: advance the smaller-max side inward
- leftMax and rightMax track running maximums from each side