---
# System prepended metadata

title: C code temp

---

# C code temp
```
#include<stdio.h>
#include <stdlib.h>

// int** threeSum(int* nums, int numsSize, int* returnSize, int** returnColumnSizes){
    
//     int i,j,target;
//     for (i = 0; i < numsSize; i++)
//     {
//         target = num[i];
//         int new_nums[numsSize-1-i];
        
//         for (j = i; j < numsSize; j++)
//         {
//             new_nums[j-i] = nums[i];
//         }
        
//     }
// }

int* twoSum(int* nums, int numsSize, int target, int *returnSize){
    int max=nums[0],min=nums[0],i;
    for(i=1;i<numsSize;i++){
        max=max>nums[i]?max:nums[i];
        min=min<nums[i]?min:nums[i];
    }
    int sft = abs(max) > abs(min) ? abs(max):abs(min);
    int arrsize = 3 * sft - min + 1;
    int *HT = calloc(arrsize--,sizeof(int));
    HT[nums[0]+sft]=-1;
    for(i=1;i<numsSize;i++){
        HT[nums[i]+sft]=i;
    }
    //*returnSize = (int*) 2;
    int *ret = malloc(2*sizeof(int)),index2;
    for(i=0;i<numsSize;i++){
        index2=target-nums[i]+sft;
        if(index2<0||index2>arrsize)continue;
        if(HT[index2] && HT[index2]!=i){
            ret[0]=nums[i];
            ret[1]=nums[HT[index2]];
            if(HT[index2]<0) ret[1]=0;
            // if(ret[0]==ret[1]){
            //     continue;
            // }
            free(HT);
            return ret;
        }
    }
    //free(HT);
    return (int*)0;
}

int main(int argc, char *argv[])
{
    int nums[] = {0,4,12,5,-16};
    int numsSize = sizeof(nums)/sizeof(nums[0]);
    int target = 0;
    int returnSize = 2;

    int *ret = twoSum(nums,numsSize,target,&returnSize);
    if (ret != 0x0) 
        printf("[%d,%d]",ret[0],ret[1]);
    else
        printf("Not found");
}
```