题目:
题解:
class Solution {
public:
vector<int> singleNumbers(vector<int>& nums) {
int eor = 0;
for (int num:nums)
eor ^= num;
int rightOne = eor & (~eor + 1); // 提取出最右的1
int onlyOne = 0;
for (int cur : nums) {
if ((cur & rightOne) != 0)
onlyOne ^= cur;
return vector<int>{onlyOne, eor^onlyOne};
}
};