Test case problem


  • 0
    G

    It says wrong answer. I think it is not my fault to make output "]".

    Input: [1], 1

    Output: ]

    Expected: []

    int removeElement(int A[], int n, int elem) {
    int *p = A, *q = A+n-1;
    int temp;
    
    while (p <= q){
        while (*p == elem){
            // switch *p and *q
            *p = *q;
            q--;
            n--;
        }
        p++;
    }
    
    return n;
    

    }


Log in to reply
 

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