“`cpp
class Solution {
public:
int arrayPairSum(vector& nums) {
sort(nums.begin(), nums.end());
int sum = 0;
for (int i = 0; i < nums.size(); i += 2)sum += nums[i];
return sum;
}
};
···
相关文章
- 561. Array Partition I
- 561. Array Partition I
- 【leetcode】Remove Duplicates from Sorted Array I & II(middle)
- [Maximize ∑arr[i]*i of an Array]
- LeetCode 1013 Partition Array Into Three Parts With Equal Sum 解题报告
- 【LeetCode】915. Partition Array into Disjoint Intervals 解题报告(Python)
- How can I add a array as a property with the following syntax?
- 北邮校赛 I. Beautiful Array(DP)
- LeetCode算法题-Array Partition I(Java实现)
- leetCode题解之Array Partition I