class Solution {
public:
int singleNumber(vector<int>& nums) {
int result = 0;
for(auto x:nums){
result ^= x;
}
return result;
}
};
相同的数字异或为零,剩下的单独的为single number
class Solution {
public:
int singleNumber(vector<int>& nums) {
int result = 0;
for(auto x:nums){
result ^= x;
}
return result;
}
};
相同的数字异或为零,剩下的单独的为single number