题解 | #只出现一次的数字#
只出现一次的数字
https://www.nowcoder.com/practice/c04bd25f0396471b90dfc30d96b9109b
class Solution {
public:
int singleNumber(vector<int>& nums) {
// write code here
int n = nums.size();
int ans = 0;
for(int i = 0; i < n; i++){
ans ^= nums[i];
}
return ans;
}
};

