Skip to content

Commit f2daef6

Browse files
Solve : Container With Most Water
1 parent 0e87ace commit f2daef6

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):
3+
left, right = 0, len(height) - 1
4+
max_area = 0
5+
while left < right:
6+
h = min(height[left], height[right])
7+
w = right - left
8+
max_area = max(max_area, h * w)
9+
if height[left] < height[right]:
10+
left += 1
11+
else:
12+
right -= 1
13+
return max_area

0 commit comments

Comments
 (0)