Missing Number (C)


  • 0
    P
    int missingNumber(int* nums, int numsSize) {
      int sum=0;
      for( int i = 0; i <= numsSize; i++)
          sum = sum^i;
      for( int i = 0; i < numsSize; i++)
          sum = sum^nums[i];
      return sum;
    }

Log in to reply
 

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