returnColumnSizes Confusion

Hello

In Leetcode challenges, do C Language submissions, what to do with returnColSize arrays.
Can any one let me know whats wrong in my code as my code shows Address error when I test
Following is code I submitted for Interval List Intersections question:

'''
int** intervalIntersection(int** A, int ASize, int* AColSize, int** B, int BSize, int* BColSize, int* returnSize, int** returnColumnSizes){

int i, j,k;

int **retArray;

i = 0;
j = 0;



 
retArray = (int**)malloc((ASize+BSize)*sizeof(int*));


returnColumnSizes  = (int**)malloc((ASize+BSize)*sizeof(int*));
for(i = 0;i<(ASize+BSize);i++)
{
    retArray[i] = (int*)malloc(2*sizeof(int));
  
    
    returnColumnSizes[i] = (int*)calloc(1,sizeof(int));
  
}

k = 0;

printf("%d %d\n",ASize,BSize);
i = j = 0;
while( i < ASize && j < BSize)
{
    int start,end;
    

    
    if (A[i][1] < B[j][0]) 
        ++i;
    else if (B[j][1] < A[i][0]) 
        ++j;
    else {
         
        start = max(A[i][0],B[j][0]);
        end = min(A[i][1],B[j][1]);
              
        if (A[i][1]< B[j][1]) 
            ++i;
        else 
            ++j;
        
        retArray[k][0] = start;
        retArray[k][1] =  end;

        
         returnColumnSizes[k][0] = 2;
        
   
        k++;
    }
    
   
     
}

*returnSize = k;

return retArray;

}
'''

Now as asked I am malloced memory for returnColumnSizes and I am filing in value 2 (as this will be my column length of intervals) in each of array element returnColumnSizes.
please guide

Comments (0)