Minimize Maximum Pair Sum in Array solution leetcode
Table of Contents
The pair sum of a pair (a,b)
is equal to a + b
. The maximum pair sum is the largest pair sum in a list of pairs.
 For example, if we have pairs
(1,5)
,(2,3)
, and(4,4)
, the maximum pair sum would bemax(1+5, 2+3, 4+4) = max(6, 5, 8) = 8
.
Given an array nums
of even length n
, pair up the elements of nums
into n / 2
pairs such that:
 Each element of
nums
is in exactly one pair, and  The maximum pair sum is minimized.
Return the minimized maximum pair sum after optimally pairing up the elements.
Minimize Maximum Pair Sum in Array solution leetcode
Example 1: Minimize Maximum Pair Sum in Array solution leetcode
Input: nums = [3,5,2,3] Output: 7 Explanation: The elements can be paired up into pairs (3,3) and (5,2). The maximum pair sum is max(3+3, 5+2) = max(6, 7) = 7.
Example 2: Minimize Maximum Pair Sum in Array solution leetcode
Input: nums = [3,5,4,2,4,6] Output: 8 Explanation: The elements can be paired up into pairs (3,5), (4,4), and (6,2). The maximum pair sum is max(3+5, 4+4, 6+2) = max(8, 8, 8) = 8.
Minimize Maximum Pair Sum in Array solution leetcode
Constraints: Minimize Maximum Pair Sum in Array solution leetcode
n == nums.length
2 <= n <= 10^{5}
n
is even.1 <= nums[i] <= 10^{5}
SOLUTION
Click here
Important Note

 To provide a better contest and ensure fairness, we listened to LeetCoders’ feedback and put in lots of thoughts behind the updated contest rule. Please check out our new contest rule which covers more scenarios with details explained.
 The penalty time of 5 minutes will be applied for each wrong submission.
 To ensure the fairness of the contest, LeetCode will hide some test cases during the contest. When users submit incorrect submissions, LeetCode will not show the hidden test cases to the users.
 The final rating of this contest will be updated within 5 working days after the contest.
 Substrings of Size Three with Distinct Characters3
 Minimize Maximum Pair Sum in Array4
 Get Biggest Three Rhombus Sums in a Grid5
 Minimum XOR Sum of Two Arrays6
Below actions are deemed contest violations

 :

 One user submitting with multiple accounts during a contest. LCUS (leetcode.com) account and LCCN (leetcodecn.com) account are considered to be separate accounts, even if both accounts belong to the same user.
 Multiple accounts submitting similar code for the same problem.
 Creating unwanted disturbances which interrupt other users’ participation in a contest.
 Disclosing contest solutions in public discuss posts before the end of a contest.


 LeetCode heavily emphasizes on the justice and fairness of our contests. We have absolutely
ZERO TOLERANCE

 for violation behaviors (such as plagiarism, cheating, etc). When a user is deemed violating contest rules, we will apply the following penalties on this user:

 First violation: LeetCoin amount resets to zero and a contest and discuss ban for 1 month.
 Second violation: Permanent account deactivation without appeal.

 Furthermore, we encourage all participants to contribute to maintaining the justice and fairness of our contest. Users who submit valid violation report(s) will earn additional LeetCoins:

 For each violating participant, the first 10 users who submit the violation report towards this participant will each earn 20 LeetCoins.
 Each user can earn up to 100 LeetCoins for reporting violations in a contest.
 Users will not be rewarded LeetCoins for reports on LCCN users.
Also Read : Stone Game VIII solution leetcode