【leetcode】错误的集合

int* findErrorNums(int* nums, int numsSize, int* returnSize){
    int* arr = (int*)malloc(2*sizeof(int));
    int* hash = (int*)calloc(numsSize,sizeof(int));    
    for (int i=0; i<numsSize; i++) hash[nums[i]-1]++;
    for (int j=0; j<numsSize; j++)
    {
        if(hash[j] == 0) arr[1] = j+1;
        else if (hash[j] == 2) arr[0] = j+1;
    }
    *returnSize = 2;
    return arr;
}
原文地址:https://www.cnblogs.com/ganxiang/p/13621678.html