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 09b4f02 commit e33db1cCopy full SHA for e33db1c
โcontainer-with-most-water/changhyumm.pyโ
@@ -0,0 +1,23 @@
1
+class Solution:
2
+ def maxArea(self, height: List[int]) -> int:
3
+ # ์๊ฐ๋ณต์ก๋ O(n2)์ผ๋ก ํ์์์
4
+ # max_amount = 0
5
+ # for i in range(len(height) - 1):
6
+ # for j in range(i + 1, len(height)):
7
+ # amount = (j-i) * min(height[i], height[j])
8
+ # max_amount = max(amount, max_amount)
9
+ # return max_amount
10
+
11
+ # ํฌํฌ์ธํฐ ํ์ฉ
12
+ # ์๊ฐ๋ณต์ก๋ O(n)
13
+ max_amount = 0
14
+ left = 0
15
+ right = len(height) - 1
16
+ while left < right:
17
+ amount = (right - left) * min(height[left], height[right])
18
+ max_amount = max(amount, max_amount)
19
+ if height[left] < height[right]:
20
+ left += 1
21
+ else:
22
+ right -= 1
23
+ return max_amount
0 commit comments