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 df768b3 commit a8cc8e1Copy full SHA for a8cc8e1
container-with-most-water/main.js
@@ -0,0 +1,28 @@
1
+/**
2
+ * @param {number[]} height
3
+ * @return {number}
4
+ */
5
+var maxArea = function(height) {
6
+ let stack = [];
7
+
8
+ let l = 0;
9
+ let r = height.length - 1;
10
11
+ while (l < r) {
12
+ let calc = Math.min(height[l], height[r]) * (r - l);
13
14
+ if ( stack.length === 0 ) {
15
+ stack.push(calc);
16
+ } else if (calc > stack[stack.length - 1]) {
17
18
+ }
19
20
+ if (height[l] < height[r]) {
21
+ l++;
22
+ } else {
23
+ r--;
24
25
26
27
+ return stack[stack.length - 1];
28
+};
0 commit comments