class Solution:
def maxArea(self, height: List[int]) -> int:
n = len(height)
V_max = 0
i,j= 0,n-1
while i < j:
V = 0
if height[i] <= height[j]:
V = (j-i)*height[i]
i += 1
else:
V = (j-i)*height[j]
j -= 1
if V > V_max:
V_max = V
return V_max
盛最多水的容器
最新推荐文章于 2024-07-09 23:56:48 发布