Array Partition
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum.
Example 1
Input
nums = [1,4,3,2]Output
4All possible pairings have sums 3, 3, and 4, so the maximum possible sum is 4.
Example 2
Input
nums = [6,2,6,5,1,2]Output
9The optimal pairing is (2, 1), (2, 5), (6, 6), giving 1 + 2 + 6 = 9.
Constraints
- 1 <= n <= 10^4
- nums.length == 2 * n
- -10^4 <= nums[i] <= 10^4