6ms C++ code XOR


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

Log in to reply
 

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