灵神同款力扣11题

def maxArea(self, height):
#我们的目的是返回最大的水容量,设置个是ans
ans=0
#需要便利,我们是双指针会减少没必要的遍历
left,right=0,len(height)-1
while left<right:
#求面积
maxarea=min(height[left],height[right])*(right-left)
ans = max(maxarea,ans)
#注意指针移动!!!!
if height[left]<height[right]:
left+=1
else:
right-=1
return ans