Skip to content

Commit 8a14a33

Browse files
authored
feat: add typescript solution to lc problem: No.1913.Maximum Product Difference Between Two Pairs (#484)
1 parent 434b9f7 commit 8a14a33

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

solution/1900-1999/1913.Maximum Product Difference Between Two Pairs/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ class Solution {
7575
}
7676
```
7777

78+
### **JavaScript**
79+
80+
```js
81+
/**
82+
* @param {number[]} nums
83+
* @return {number}
84+
*/
85+
var maxProductDifference = function(nums) {
86+
nums.sort((a, b) => a - b);
87+
let n = nums.length;
88+
let ans = nums[n - 1] * nums[n - 2] - nums[0] * nums[1];
89+
return ans;
90+
};
91+
```
92+
7893
### **...**
7994

8095
```

solution/1900-1999/1913.Maximum Product Difference Between Two Pairs/README_EN.md

+15
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ class Solution {
9696
}
9797
```
9898

99+
### **JavaScript**
100+
101+
```js
102+
/**
103+
* @param {number[]} nums
104+
* @return {number}
105+
*/
106+
var maxProductDifference = function(nums) {
107+
nums.sort((a, b) => a - b);
108+
let n = nums.length;
109+
let ans = nums[n - 1] * nums[n - 2] - nums[0] * nums[1];
110+
return ans;
111+
};
112+
```
113+
99114
### **...**
100115

101116
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
var maxProductDifference = function(nums) {
6+
nums.sort((a, b) => a - b);
7+
let n = nums.length;
8+
let ans = nums[n - 1] * nums[n - 2] - nums[0] * nums[1];
9+
return ans;
10+
};

0 commit comments

Comments
 (0)