Skip to content

Commit 323fa15

Browse files
committed
11. Container With Most Water Solution
1 parent 5008b80 commit 323fa15

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# 11. Container With Most Water
2+
3+
# Use two pointesr
4+
class Solution:
5+
def maxArea(self, height: List[int]) -> int:
6+
left, right = 0, len(height) -1
7+
container = 0
8+
9+
while left < right:
10+
cal = ((right - left) * min(height[left], height[right]))
11+
container = max(container, cal)
12+
if height[left] > height[right]:
13+
right -= 1
14+
else:
15+
left += 1
16+
return container

0 commit comments

Comments
 (0)