Short C++ XOR


  • -1
    1
    class Solution {
    public:
        int singleNonDuplicate(vector<int>& nums) {
            int res = 0;
            for(auto n : nums)
                res ^= n;
            return res;
        }
    };
    

Log in to reply
 

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