Code not working in latched platform but in my system for prob Fizz Buzz (412)


  • 0
    A

    char** fizzBuzz(int n, int* returnSize) {
    char array;
    array = (char
    )malloc(sizeof(nsizeof(char)));
    int i=0;
    for(i=0;i<n;i++){
    array[i] = (char*)malloc(20*sizeof(char));
    printf(i);
    }
    for(i =0; i<n ;i++)
    {
    int num = i+1;
    if((num%3==0) && (num%5==0))
    {
    strcpy(array[i],"FizzBuzz");
    }
    else if(num%3 ==0)
    {
    sprintf(array[i],"%s","Fizz");
    }
    else if(num%5 ==0)
    {
    sprintf(array[i],"%s","Buzz");
    }
    else
    {
    char cad[9];
    sprintf(array[i],"%d",num);
    }
    printf(array[i]);
    }
    return array;
    }


Log in to reply
 

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