一、leetcode地址
https://leetcode.com/problems/container-with-most-water/
二、问题描述
三、代码实现
语言:Python3
代码:
class Solution:
def maxArea(self, height: List[int]) -> int:
i = 0;j = len(height)-1
maxArea = 0
while i != j:
if height[i] < height[j]:
area = (j-i)*height[i]
if area > maxArea:maxArea = area
i += 1
else:
area = (j-i)*height[j]
if area > maxArea:maxArea = area
j -= 1
return maxArea