My simple c++ solution


  • 0
    K
    class Solution {
    public:
    int singleNumber(vector<int>& nums) {
        int res=0, temp, sum;
        for(int i=0;i<32;i++)
        {
            sum=0;
            temp=(1<<i);
            for(int j=0;j<nums.size();j++)
            {
                if(temp & nums[j])sum++;
            }
            if(sum%2)res|=temp;
        }
        return res;
    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.