You're given an array where height[i] represents a vertical line at position i. Find two lines that, together with the x-axis, form a container holding the most water.
For height = [1, 8, 6, 2, 5, 4, 8, 3, 7], the answer is 49. Lines at positions 1 and 8 (heights 8 and 7) form a container with width 7, so area = min(8, 7) × 7 = 49.
Checking all pairs takes . How can you find the maximum in a single pass?
Constraints: , heights from to .