Why my my solution cannot pass but it pass in my IDE?


  • 0
    S
    #include<stdlib.h>
    

    void moveZeroes(int* nums, int numsSize) {
    int *p = nums, *newarr, q;
    if((newarr = (int
    )calloc(numsSize, (int)sizeof(char))) == NULL){
    printf("Not able to allocate momory!\n");
    }
    q = newarr;
    while(p < nums + numsSize){
    if(*p != 0){
    *q = *p;
    q++;
    }
    p++;
    }
    while(q < newarr + numsSize){
    *q = 0;
    q++;
    }
    p = nums, q = newarr;
    while(p < nums + numsSize){
    *p = *q;
    p++, q++;
    }
    free(newarr);
    }


Log in to reply
 

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