Container With Most Water LeetCode solution in JavaScript

1
/**
2
* @param {number[]} height
3
* @return {number}
4
*/
5
var maxArea = function (height) {
6
let max = -1;
7

8
/*===========BRUTE FORCE========== */
9
for (let i = 0; i < height.length - 1; i++) {
10
let currMax = -1;
11
for (let j = i + 1; j < height.length; j++) {
12
let min = Math.min(height[i], height[j]);
13
let length = j - i;
14
let filled = min * length;
15
if (filled > currMax) {
16
currMax = filled;
17
}
18
}
19
if (currMax > max) {
20
max = currMax;
21
}
22
}
23

24
return max;
25
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0