C 6MS beat 66.82%


  • 0
    L
    int missingNumber(int* nums, int numsSize) {
        
        int sumOneToNumsSize=numsSize*(numsSize+1)/2;
        int sumOfNums=0;
        
        for(int i=0;i<numsSize;++i)
        {
            sumOfNums+=nums[i];
        }
        
        return sumOneToNumsSize-sumOfNums;
    }
    

Log in to reply
 

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