Skip to content

Commit 455955e

Browse files
committed
Week 6: Container-with-most-water
1 parent 9f67102 commit 455955e

File tree

1 file changed

+13
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)