Skip to content

Commit 7811238

Browse files
committed
container-with-most-water solution
1 parent b74d250 commit 7811238

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

0 commit comments

Comments
 (0)