We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2c89729 commit 99fabadCopy full SHA for 99fabad
solution/011. Container With Most Water/Solution.js
@@ -0,0 +1,18 @@
1
+const maxArea2 = function(height){
2
+ let result = 0;
3
+ for(let i = 0; i < height.length; i++){
4
+ for(let j = i + 1; j < height.length; j++){
5
+ result = Math.max(result, Math.min(height[i],height[j])*(j-i));
6
+ }
7
8
+ return result;
9
+};
10
+
11
+const maxArea = function(height){
12
+ let result = 0, l = 0, r = height.length - 1;
13
+ while(l < r){
14
+ result = Math.max(result, Math.min(height[l],height[r])*(r-l));
15
+ height[l] < height[r] ? l++ : r--;
16
17
18
+}
0 commit comments