Skip to content

Commit f640440

Browse files
author
sejineer
committed
container-with-most-water solution
1 parent fcfd652 commit f640440

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+
"""
2+
시간 복잡도: O(N)
3+
공간 복잡도: O(1)
4+
"""
5+
class Solution:
6+
def maxArea(self, height: List[int]) -> int:
7+
result = 0
8+
start, end = 0, len(height) - 1
9+
10+
while start < end:
11+
area = (end - start) * min(height[start], height[end])
12+
result = max(result, area)
13+
if height[start] < height[end]:
14+
start += 1
15+
else:
16+
end -= 1
17+
return result

0 commit comments

Comments
 (0)