Container With Most Water

You are given an integer array height of length n representing n vertical lines drawn such that the two endpoints of the i-th line are (i, 0) and (i, height[i]). The task is to find two lines that together with the x-axis form a container that can hold the maximum amount of water. The container cannot be slanted.

Constraints

  • n == height.length
  • 2 <= n <= 100000
  • 0 <= height[i] <= 10000
Saving… · 2 lines
class Solution:
def containerWithMostWater(self, height: List[int]) -> int:
Console

Click Run to execute sample tests.