Array Partition
Easy
Topics
Given an array nums of 2n integers, group them into n pairs so that the sum of min(pair) over all pairs is maximized, and return that maximum sum.
Example 1
Input: nums = [1,4,3,2] Output: 4 Explanation: Pairs (1,2) and (3,4) give 1 + 3 = 4.
Example 2
Input: nums = [6,2,6,5,1,2] Output: 9
Constraints
- 1 <= n <= 10^4
- nums.length == 2n
- -10^4 <= nums[i] <= 10^4
Run ⌘' · Submit ⌘⏎