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 3a45e8a commit f59a4d7Copy full SHA for f59a4d7
โcontainer-with-most-water/yyyyyyyyyKim.pyโ
@@ -0,0 +1,20 @@
1
+class Solution:
2
+ def maxArea(self, height: List[int]) -> int:
3
+
4
+ # ํฌํฌ์ธํฐ(two pointer) : ์๊ฐ๋ณต์ก๋ O(n)
5
+ left, right = 0, len(height)-1
6
+ answer = 0
7
8
+ while left < right:
9
+ width = right - left # ์ธ๋ฑ์ค ์ฐจ์ด๊ฐ ๋ ๋ฒฝ ์ฌ์ด์ ๊ฑฐ๋ฆฌ(๋๋น)
10
+ h = min(height[left], height[right]) # ๋ ๋ฎ์ ๋ฒฝ์ ๊ธฐ์ค์ผ๋ก ๋ฌผ์ ์ฑ์ธ ์ ์์(๋์ด)
11
12
+ answer = max(answer, width * h) # ์ต๋ ๋์ด ์ ๋ฐ์ดํธ
13
14
+ # ํฌ์ธํฐ ์ด๋(๋ ๋ฎ์ ๊ฐ์ ๊ฐ์ง ํฌ์ธํฐ๋ฅผ ์ด๋)
15
+ if height[left] < height[right]:
16
+ left += 1
17
+ else:
18
+ right -= 1
19
20
+ return answer
0 commit comments