void recursion(int* nums, int numsSize, int* returnSize, int* returnColumnSizes, int cnt, int** arr, int* temp,int* hash){
    if (cnt == numsSize){
        arr[(*returnSize)] = (int*)calloc(numsSize + 1, sizeof(int));
        memcpy(arr[(*returnSize)], temp, cnt*sizeof(int));
        returnColumnSizes[(*returnSize)++] = cnt;
        return;
    }
    for (int i = 0; i<numsSize; i++){
        if (hash[i]) continue;
        hash[i]++;
        temp[cnt] = nums[i];
        recursion(nums, numsSize, returnSize, returnColumnSizes, cnt + 1, arr, temp,hash);
        hash[i]--;
    }
}
int** permute(int* nums, int numsSize, int* returnSize, int** returnColumnSizes){
    int** arr = (int**)calloc(sizeof(int*), 1000);
    int* hash = (int*)calloc(sizeof(int), numsSize);
    *returnSize = 0;
    *returnColumnSizes = (int*)calloc(sizeof(int), 1000);
    int temp[1000] = { 0 };
    recursion(nums, numsSize, returnSize, *returnColumnSizes, 0, arr, temp, hash);
    return arr;
}