Skip to content

Commit 4c8d476

Browse files
committed
Create 1464.数组中两元素的最大乘积.js
1 parent a1b67b4 commit 4c8d476

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
var maxProduct = function(nums) {
6+
let max = 0;
7+
for (let i = 0; i < nums.length; i++) {
8+
for (let j = i + 1; j < nums.length; j++) {
9+
max = Math.max(max, (nums[i] - 1) * (nums[j] - 1));
10+
}
11+
}
12+
return max;
13+
};

0 commit comments

Comments
 (0)