11. Container With Most Water

Practice Container With Most Water for free on NudgeCode: Medium, Two Pointers pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

height[i] is the height of a vertical line at position i. Pick two lines; together with the x-axis they hold water up to the shorter line. Return the largest amount of water (width times the shorter height) any pair can hold.

Example

height = [1,8,6,2,5,4,8,3,7]  ->  49   (lines at index 1 and 8: min(8,7) * 7)
height = [1,1]                ->  1

Constraints