C++ O(n) Solution still shows, Time Limit Exceeded


#1
int Solution::removeDuplicates(vector &A) { vector::iterator it;
for(int i=0;i<A.size()-1;i++){
    it=A.begin()+i;
    if(A[i]==A[i+1]) {A.erase(it);i--;}
}
return A.size();

}


#2

erase is O(n) so total complexity is n^2 try swaping unequals