LeetCode 561. Array Partition I Posted on 2021-02-16 Edited on 2024-11-24 In LeetCode 12345678910class Solution {public: int arrayPairSum(vector<int>& nums) { sort(nums.begin(), nums.end()); int n = nums.size(), ans = 0; for (int i = 0; i < n; i += 2) ans += nums[i]; return ans; }};