Container With Most Water
Vertical lines have heights height[i] at horizontal coordinate i. Choose two lines forming the largest water container and return its area: their distance times the shorter height.
Example 1
height = [3,1,4,2,5]12Explanation
Indices 0 and 4 give width 4 and limiting height 3, hence area 12.
Example 2
height = [0,0]0Explanation
Both lines have height zero, so the area is zero.
Example 3
height = [6,6]6Explanation
Two height-six lines one unit apart hold area 6.
Constraints
- 2 <= len(height) <= 100000
- Heights are 0..10000
Function contract
maxAreaArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 34 cases, on your device.
[3,1,4,2,5]