loading…
heights[i] is the height of a vertical line at position i. Write max_area(heights) that returns the most water two lines can hold: min(h[i], h[j]) * (j - i).
max_area([1, 8, 6, 2, 5, 4, 8, 3, 7]) -> 49
Stuck on the idea itself? The two pointers lesson walks through the pattern from scratch.