leetcode 136. 只出现一次的数字 easy
题目描述:
解题思路:
a^a = 0, a^0 = a 异或满足交换律结合律
代码:
class Solution {
public:
int singleNumber(vector<int>& nums) {
int res = 0;
for (auto num: nums)
res ^= num;
return res;
}
};