Simple bit manipulation solution


  • 1
    M
    int missingNumber(int* nums, int numsSize) {
        int i,x=nums[0],y=0;
        for(i=1;i<numsSize;i++)
        x^=nums[i];
        for(i=1;i<=numsSize;i++)
        y^=i;
        return x^y;
    }

Log in to reply
 

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