Simple question, the code seems to be pretty elegant though :)

    int removeElement(int A[], int n, int elem) {
        // IMPORTANT: Please reset any member data you declared, as
        // the same Solution instance will be reused for each test case.
        int lc = 0;
        for(int i = 0 ; i< n ; i++){
            
            if(A[i] == elem){
                lc++;
            } else{
                A[i - lc] = A[i];
            }
        }
        return n - lc;
    }