暴力求解会超时,用双指针
class Solution:
def maxArea(self, height: List[int]) -> int:
#双指针
start,end=0,len(height)-1
area,max=0,0
while start<end:
area=(end-start)*min(height[start],height[end])
if height[start]<height[end]:
start+=1
else:
end-=1
if max<area:
max=area
return max