11 Container with most Water

This commit is contained in:
2024-05-07 12:51:57 -04:00
parent 5daed67768
commit 1bf5d2ab15
@@ -0,0 +1,13 @@
class Solution:
def maxArea(self, height: list[int]) -> int:
l = 0
r = len(height) - 1
max_area = (r-l) * min(height[l], height[r])
while (r-l > 2):
if (height[l] <= height[r]):
l += 1
else:
r -= 1
max_area = max(max_area, (r-l) * min(height[l], height[r]))
return max_area