Help!! Runtime error


  • 0
    L
    int *getRow(int rowIndex) {
        if (rowIndex<0) return NULL;
        int row[rowIndex+1];
        row[0]=1;
        row[rowIndex]=1;
        int i,j;
        for(i=1;i<rowIndex;i++) {
            row[i]=1;
            for(j=i;j>0;j--) {
                row[j]=row[j]+row[j-1];
            }
        }
        return row;
    }
    

    Have no idea how to fix it. Please help.
    Actually I don't even know what was the problem causing runtime error...

    Another question is, I'm returning a local variable out of the method, would that cause any problem?


Log in to reply
 

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