Container With Most Water
Each item height[i] of the list height is a vertical wall standing at position i. Pick two walls: together with the floor they form a container whose area is the distance between them times the shorter of the two heights.
Return the largest area you can get from any pair of walls.
Example 1
height [1,8,6,2,5,4,8,3,7]
returns 49
Walls at index 1 (height 8) and 8 (height 7): width 7, height 7, area 49.
Example 2
height [3,3]
returns 3
One pair: width 1 times height 3.
Constraints
2 <= len(height) <= 1000 <= height[i] <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.