Skip to content

Commit 35fe589

Browse files
author
jinbeom
committed
Container With Most Water Solution
1 parent 4376514 commit 35fe589

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

container-with-most-water/kayden.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 시간복잡도: O(N)
2+
# 공간복잡도: O(N)
3+
class Solution:
4+
def maxArea(self, height: List[int]) -> int:
5+
l, r = 0, len(height) - 1
6+
answer = 0
7+
8+
while l < r:
9+
10+
if height[l] < height[r]:
11+
answer = max(answer, (r - l) * height[l])
12+
l += 1
13+
else:
14+
answer = max(answer, (r - l) * height[r])
15+
r -= 1
16+
17+
return answer

0 commit comments

Comments
 (0)