Sharing my simple C++ solution


  • 0
    A
    int removeElement(int A[], int n, int elem) 
    {
        int boarder=n;
        int i=0;
        while(i<boarder)
        {
            if(A[i]==elem)
                A[i]=A[--boarder];
            else
                i++;
        }
        return boarder;
    }

Log in to reply
 

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