Given a length of n Array of integers for height . Yes n Vertical line , The first i The two ends of the line are (i, 0) and (i, height[i]) .
Find two of them , Make them x A container of shafts can hold the most water .
Return the maximum amount of water that the container can store .
def maxArea(self, height: List[int]) -> int:
i,j,res = 0,len(height)-1,0
while i<j:
if height[i]<height[j]:
res = max(res,height[i]*(j-i))
i +=1
else:
res = max(res,height[j]*(j-i))
j -=1
return res
I believe you are familiar wit
Study Python There are many di