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 29d0b7e commit c96e459Copy full SHA for c96e459
container-with-most-water/yeeZinu.js
@@ -0,0 +1,24 @@
1
+/**
2
+ * @param {number[]} height
3
+ * @return {number}
4
+ */
5
+
6
+var maxArea = function (height) {
7
+ let max = 0; // 최대값
8
+ let left = 0; // 왼쪽 값
9
+ let right = height.length - 1; // 오른쪽 값
10
11
+ // 왼쪽과 오른쪽을 하나씩 줄여가며 가운데서 만날 때 까지 반복
12
+ while (left < right) {
13
+ // 최대값 = 가로길이(오른쪽 값 - 왼쪽 값) * 세로길이(왼쪽 값, 오른쪽 값 중 더 작은 값)
14
+ max = Math.max(max, (right - left) * Math.min(height[left], height[right]));
15
+ // 오른쪽 세로가 더 높다면 왼쪽 값 증가
16
+ if (height[left] < height[right]) {
17
+ left++;
18
+ }
19
+ else {
20
+ right--;
21
22
23
+ return max;
24
+};
0 commit comments