Getting MLE for all the cases


#1

This is my code :

int Solution::removeElement(vector &A, int B) {

int n=A.size();
int l=0;
for(int i=0;i<n;++i){
if(A[i]!=B)
A[l++]=A[i];
}

A.erase(A.begin()+l,A.end());

return A.size();
}

I’ve tried :

  1. erasing the not needed elements
  2. filling the unnecessary elements with zeroes and then returning
  3. directly returning the new size without making any changes to the vector
    In all of these cases it’s giving MLE , I think there’s something wromg with the judge.