Skip to content

Commit 612bf66

Browse files
committed
container with most water solution
1 parent 90309d5 commit 612bf66

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

container-with-most-water/devyejin.py

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

0 commit comments

Comments
 (0)