We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8d08322 commit 7345f01Copy full SHA for 7345f01
container-with-most-water/hu6r1s.py
@@ -0,0 +1,20 @@
1
+
2
+class Solution:
3
+ """
4
+ 1. 브루트포스와 같이 전부 길이를 대조해보고 하면 시간복잡도가 터질 것.
5
+ 투포인터 방식을 활용하면 됨. 투포인터에 대한 문제가 코딩테스트로 많이 나올 것 같음.
6
+ 확실하게 공부 필요.
7
8
+ def maxArea(self, height: List[int]) -> int:
9
+ max_area = 0
10
+ start, end = 0, len(height) - 1
11
+ while start < end:
12
+ area = (end - start) * min(height[start], height[end])
13
+ max_area = max(area, max_area)
14
15
+ if height[start] <= height[end]:
16
+ start += 1
17
+ else:
18
+ end -= 1
19
20
+ return max_area
0 commit comments