力扣—盛水最多的容器
'''设置两个指针,从前和往中间遍历'''
from typing import List
class Solution:
def maxArea(self, height: List[int]) -> int:
N = len(height)
i = 0
j = N-1
max_area = 0
while i < j:
c = (j-i)*min(height[i], height[j])
if c > max_area:
max_area = c
if height[i] > height[j]:
j -= 1
else:
i += 1
return max_area
# %%
s = Solution()
print(s.maxArea([1,8,6,2,5,4,8,3,7]))