MLE error on submission


#1

It says “It does not matter what is left beyond the expected length.” in the problem statement. However, the solution expects that the modified vector should have a size equal to the expected length. Please fix this problem.


#2

Yeah I’m having the same problem, even though I have solution as the editorial. Please fix it asap.


#3

resize the array/vector before submitting!! it will work
i dont know why IB is such a pain!


#4

You do not need to resize the array, but return the index of the position… see my example:

public int removeElement(ArrayList<Integer> a, int b) {
    int ptr = 0;
    for (int i = 0 ; i < a.size() ; i++) 
        if (a.get(i) != b) 
            a.set(ptr++,a.get(i));

    return ptr;
}