LC 面试题56

class Solution {
public:
    vector<int> singleNumbers(vector<int>& nums) {
        int total=0;
        for(int i:nums) total^=i;
        int one=1;
        while((one&total)==0) one<<=1;
        int a=0,b=0;
        for(int i:nums){
            if((i&one)==0) a^=i;
            else b^=i;
        }
        return {a,b};
    }
};
原文地址:https://www.cnblogs.com/FEIIEF/p/12792173.html