Skip to content

Commit 80d8807

Browse files
committed
adding container with most water
1 parent ebd1384 commit 80d8807

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def maxArea(self, height: List[int]) -> int:
3+
left = 0
4+
right = len(height) - 1
5+
max_area = 0
6+
while left < right:
7+
max_area = max(max_area, min(height[left], height[right]) * (right - left))
8+
if height[left] < height[right]:
9+
left += 1
10+
else:
11+
right -= 1
12+
return max_area

0 commit comments

Comments
 (0)