Last active
September 21, 2017 09:27
-
-
Save freelze/7b7feadaf09eb25c9fbd84ca55e1d03c to your computer and use it in GitHub Desktop.
Runtime: 109 ms , Your runtime beats 4.36 % of cpp submissions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
class Solution { | |
public: | |
int arrayPairSum(vector<int>& nums) { | |
vector<int>::size_type sz = nums.size(); | |
sort(nums.begin(),nums.end()); | |
int total = 0; | |
for(int i=0;i<sz;i+=2) | |
{ | |
total+=nums[i]; | |
} | |
return total; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment