C solution use xor


  • 0
    B

    class Solution {
    public:
    int singleNonDuplicate(vector<int>& nums) {
    int res = 0;
    for(int i = 0;i<nums.size();i++){
    res ^= nums[i];
    }
    return res;
    }
    };


Log in to reply
 

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