链接:https://leetcode-cn.com/problems/array-partition-i/
数学题,排序后从最小元素开始,逢二选一即可。
java代码:
class Solution {
public int arrayPairSum(int[] nums) {
Arrays.sort(nums);
int result = 0;
for(int i = 0;i<nums.length;i+=2)
{
result+=nums[i];
}
return result;
}
}