Skip to content

Commit 9a60e06

Browse files
authored
Create 1877-minimize-maximum-pair-sum-in-array.js
1 parent 3487c2f commit 9a60e06

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 minPairSum = function(nums) {
6+
nums.sort((a, b) => a - b)
7+
let res = 0
8+
for(let i = 0, limit = nums.length / 2; i < limit; i++) {
9+
res = Math.max(res, nums[i] + nums[nums.length - 1 - i])
10+
}
11+
12+
return res
13+
};

0 commit comments

Comments
 (0)