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 b263e24 commit 791de24Copy full SHA for 791de24
container-with-most-water/hyunjung-choi.kt
@@ -0,0 +1,22 @@
1
+/**
2
+ * 시간 복잡도: O(n)
3
+ * 공간 복잡도: O(1)
4
+ */
5
+
6
+class Solution {
7
+ fun maxArea(height: IntArray): Int {
8
+ var i = 0
9
+ var j = height.size - 1
10
+ var max = 0
11
12
+ while (i < j) {
13
+ val h = minOf(height[i], height[j])
14
+ max = maxOf(max, (j - i) * h)
15
16
+ if (height[i] <= height[j]) i++
17
+ else j--
18
+ }
19
20
+ return max
21
22
+}
0 commit comments