Container with most water solution
class Solution:
def maxArea(self, height: List[int]) -> int:
l=0
r=len(height)-1
area=0
for i in range(len(height)):
x=height[l]
y=height[r]
area=max(area,(r-l)*min(x,y))
if height[l]<height[r]:
l+=1
else:
r-=1
return area
Comments
Post a Comment
If you have any doubt you ask me in comment section