Skip to content

Commit d807266

Browse files
committed
feat: container-with-most-water
1 parent 61d582f commit d807266

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 시간 복잡도 : O(n)
2+
# 공간 복잡도 : O(1)
3+
# 문제 유형 : Two Pointer
4+
class Solution:
5+
def maxArea(self, height: List[int]) -> int:
6+
left, right = 0, len(height) - 1
7+
max_area = 0
8+
9+
while left < right:
10+
max_area = max(max_area, (right - left) * min(height[left], height[right]))
11+
if height[left] < height[right]:
12+
left += 1
13+
else:
14+
right -= 1
15+
16+
return max_area
17+

0 commit comments

Comments
 (0)