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 b7b6ee8 commit 52d8c2aCopy full SHA for 52d8c2a
βcontainer-with-most-water/uraflower.js
@@ -0,0 +1,28 @@
1
+/**
2
+ * μ£Όμ΄μ§ λ°°μ΄μμ (λ μμ μ€ μμ κ°) * (λ μμμ μΈλ±μ€ μ°¨μ΄)μ μ΅λκ°μ λ°ννλ ν¨μ
3
+ * @param {number[]} height
4
+ * @return {number}
5
+ */
6
+const maxArea = function(height) {
7
+ let left = 0;
8
+ let right = height.length - 1;
9
+ let max = 0;
10
+
11
+ while (left < right) {
12
+ const w = right - left;
13
+ const h = Math.min(height[left], height[right]);
14
15
+ max = Math.max(max, w * h);
16
17
+ if (height[left] <= height[right]) {
18
+ left++;
19
+ } else {
20
+ right--;
21
+ }
22
23
24
+ return max;
25
+};
26
27
+// μκ°λ³΅μ‘λ: O(n)
28
+// 곡κ°λ³΅μ‘λ: O(1)
0 commit comments