My code is not running on leetcode but on local its working for the testcase

For below problem :
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

I have written the below code , which is working on my local but on leetcode its not accepting for the same testcases,Can someone please assist me :

/**

  • Note: The returned array must be malloced, assume caller calls free().
    /
    int
    twoSum(int* nums, int numsSize, int target, int* returnSize){

    //static int b[2];
    int i=0,j=0,first_val,second_val,diff_val;
    for(i=0;i<numsSize-1;i++)
    {
    first_val=nums[i];
    diff_val= target-first_val;
    for(j=i+1;j<numsSize;j++)
    {
    if(diff_val == nums[j])
    {

             returnSize= (int *)malloc(2*sizeof(int));
            if(returnSize != NULL)
            {
          *(returnSize+0)= i;             
          *(returnSize+1)=j ; 
          
        
            return returnSize;
            }
        }
        
     }
        

    }
    return NULL;

}

Comments (0)