C solution, problem for understanding " columnSizes".


  • 0
    L

    In my code, I use printf's function to show my result. And I get the correct answer. However, I cannot pass the test because of columnSizes. In my code, I write as follows:
    '''
    returnSize = boardRowSize;
    columnSizes = (int
    *)malloc( sizeof(int*) );
    columnSizes = (int)malloc( (*returnSize) * sizeof(int) );
    for( i = 0; i < boardRowSize; i ++)
    (*columnSizes)[i] = boardColSize;
    '''
    And the result shows like this:["","","",""]
    I really don't know where my problem is. Can you help me?


  • 0
    T

    I have the same problem,too.
    char** updateBoard(char** board, int boardRowSize, int boardColSize, int* click, int clickSize, int** columnSizes, int* returnSize)
    {
    int i,j;
    returnSize=boardRowSize;
    columnSizes=(int)malloc(boardRowSize
    sizeof(int));
    for(i=0;i<boardRowSize;i++)
    {
    (*columnSizes)[i]=boardColSize;
    }
    return board;
    }
    It has problem.
    I don't know how to solve it.


  • 0
    T
    This post is deleted!

Log in to reply
 

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