LeetCode Single Number
Method I
class Solution {
public:
int singleNumber(int A[], int n) {
int mySum = 0, sum = 0;
map<int, int>toolMap;
for(int i = 0; i<n; i++)
{
sum+=A[i];
toolMap.insert(pair<int, int>(A[i], 0));
}
for(map<int, int>::iterator iter = toolMap.begin(); iter!=toolMap.end();++iter)
{
mySum+= iter->first;
}
int re = mySum*2 - sum;
return re;
}
};