Javascript solution using XOR


  • 0
    R
    var missingNumber = function(nums) {
        var res = nums.length;
        
        for(var i = 0; i < nums.length; i++){
            res ^= (i ^ nums[i]);
        }
        
        return res;
    };

Log in to reply
 

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