C solution 49ms,beats 95.81%,with hashmap


  • 0
    int* findDisappearedNumbers(int* nums, int numsSize, int* returnSize)
    {
        int i;
        *returnSize=0;
        int *return_array=(int *)malloc (sizeof (int )*numsSize);
        for(i=0;i<numsSize;i++)
            return_array[i]=0;
        for (i=0;i<numsSize;i++)
            return_array[nums[i]-1]=1;
        for (i=0;i<numsSize;i++)
        {
            if (return_array[i]==0)
            {
                return_array[*returnSize]=i+1;
                (*returnSize)++;
            }
        }
        return(return_array);
    }
    

    0_1493046575192_QQ截图20170424224424.png


Log in to reply
 

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