Approach

This seems to be a difficult problem, but it is acutally simple.

When we select pairs for a <= b <= c <= d, it is obvious that selecting (a,d) with (b,c) can achieve the minimax; therefore, we only need to sort the original array and find the max with two pointers from head and tali.

Code

class Solution {
public:
    int minPairSum(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        int sum = INT_MIN;
        int n = nums.size();
        for(int i = 0 ; i < n/2 ; ++i) {
            sum = max(sum, nums[i] + nums[n-1-i]);
        }
        return sum;
    }
};