Easy to understand C solution


  • 0
    C

    int missingNumber(int* nums, int numsSize) {

    int sum1 = numsSize*(numsSize+1)/2; 
    int sum2 = 0;
        
    for (int i=0; i<numsSize; i++)
        sum2 += nums[i];
        
    return (sum1-sum2);
    

    }


Log in to reply
 

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