Show my easy code


  • 0
    7
    int missingNumber(int* nums, int numsSize) {
        int sum = (numsSize - 1)*numsSize/2;
        int total = 0;
        for(int i=0;i<numsSize;i++){
            total += nums[i];
        }
        
        if(total == sum){
            return numsSize;
        }
        else{
            return (sum + numsSize - total);
        }
    }

Log in to reply
 

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