C Solution: Bugged?


  • 0
    P

    Returning a malloced array here does not reach the output. I always get "[]" as my output regardless.

    int* result = (int*)malloc( sizeof(int) * *returnSize);
    

    *returnSize is zero in the first test case

        int* result = (int*)malloc( sizeof(int) * 2);
        result[0] = 1;
        result[1] = 2;
        return result;
    

    Even if I return that, I still get "[]" as output.

    Am I missing something? I am not great at C


  • 2
    C

    returnsSize also needs to be set. The function is called with returnsSize set to 0 by default.


Log in to reply
 

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