Container with Most Water (Leetcode 11)
Problem Link: https://leetcode.com/problems/container-with-most-water/
class Solution:
def maxArea(self, height: List[int]) -> int:
n=len(height)
ans=0
i=0
j=n-1
while(i<j):
width=j-i
ans=max(ans,width*(min(height[i],height[j])))
if(height[i]<=height[j]):
i+=1
else:
j-=1
return ans
Last updated