11. Container With Most Water
Last updated
Last updated
Input: [1,8,6,2,5,4,8,3,7]
Output: 49class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
l = 0
r = len(height) - 1
maxWater = 0
while l < r:
maxWater = max(maxWater, min(height[l], height[r]) * (r - l))
if height[l] < height[r]:
l += 1
else:
r -= 1
return maxWater