题解 | #盛水最多的容器#
盛水最多的容器
https://www.nowcoder.com/practice/3d8d6a8e516e4633a2244d2934e5aa47?tpId=295&tqId=2284579&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E7%25AE%2597%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D295
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param height int整型一维数组
# @return int整型
#
class Solution:
def maxArea(self , height: list[int]) -> int:
# write code here
maxAreas =0
length =len(height)
i=0
j=length-1
while i <j:
Areas = min(height[i],height[j]) *(j-i)
maxAreas =max(Areas,maxAreas)
if height[i]<=height[j]:
i+=1
else:
j-=1
return maxAreas
