Intuitive Javascript Solution

  • 0
    var missingNumber = function(nums) {
        let n = nums.length, missingNumber = n;
        // index xor number cancels out the same values and yeld the outstanding number 
        for (let i = 0; i < n; i++) 
            missingNumber ^= i ^ nums[i];
        return missingNumber;

Log in to reply

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