Any correct answer by C?


  • 0
    A

    what is the second argument "outputSize" for in C. my code here:

        int *grayCode(int n) {
            int size = 1 << n;
            int *gray_array = malloc(size);
    
            if (n == 0) {
                gray_array[0] = 0;
            }else {
                gray_array = grayCode(n-1);
                for (int i = (size - 1), j = 0 ; i >= size / 2 ; i --, j ++) {
                    gray_array[i] = gray_array[j] + (1 << (n - 1));
                }
            }
            return gray_array;
        }
    

    get error "line 43, too many arguments...."


Log in to reply
 

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