Runtime error, c code


  • 0
    I
    int* getRow(int rowIndex, int* returnSize) {
        int i,t=1;
        for (i=0;i<rowIndex/2+1;i++){
            returnSize[i]=t;
            returnSize[rowIndex-i]=t;
            t*=rowIndex-i;
            t/=i+1;
        }
        return returnSize;
    }
    

    Last executed input: 6

    That someone can tell me why it happened? thx


  • 0
    I

    You should not return the "returnSize" array, instead, init another array, put the numbers in that array, and then return the array.

    *returnSize should equal to the size of your array, in this case, equal to rowIndex+1.


  • 0
    I

    I see, thank you


Log in to reply
 

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