We’re preparing your current view and syncing the latest data.
Minimize Maximum Pair Sum
gfgYou are given an integer array nums consisting of 2 * n integers. Your task is to partition these integers into n pairs such that the maximum sum of any pair is minimized. Return the minimized maximum pair sum.
Formally, you want to partition nums into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the maximum value of ai + bi among all pairs is minimized.
An array nums of integers with length 2n.
Return an integer representing the minimized maximum pair sum.
2 <= nums.length == 2 * n <= 10^5 1 <= nums[i] <= 10^5
Example 1
Input
[3, 5, 2, 3]
Output
7
Explanation
After sorting: [2, 3, 3, 5]. Pairings: (2,5) and (3,3). The sums are 7 and 6, so the minimized maximum pair sum is 7.