Always have runtime error programed in c


  • 0
    V
    int** generate(int numRows, int** columnSizes, int* returnSize) {
        
        *returnSize = numRows;
        int **returnArray = (int **)malloc(sizeof(int*)*numRows);
        for(int i = 0;i < numRows;i++)
        {
            *(*columnSizes+i) = 1+i;
            *(returnArray+i) = (int *)malloc(sizeof(int)*(1+i));
        }
        
        for(int i = 0;i < numRows;i++)
        {
            for(int j = 0;j <= i;j++)
            {
                if(j == 0 || j == i)
                {
                    *(*(returnArray+i)+j) = 1;
                }
                else
                {
                    *(*(returnArray+i)+j) =  *(*(returnArray+i-1)+j-1) + *(*(returnArray+i-1)+j);
                }
            }
        }
        return returnArray;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.