I have the following code got TLE:

```
public int removeDuplicates(int[] A) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
if(A.length == 0) return A.length;
int curInt = A[0];
int len = A.length;
for(int i = 1; i < len; i++){
if(curInt == A[i]){
for(int j = i; j < len-1; j++){
A[j]=A[j+1];
}
len--;
i--;
}
else{
curInt = A[i];
}
}
return len;
}
```

It is very intuitive: traverse the array and keep track of the integer you are comparing to. If the ith element in the array equals the integer, remove it; otherwise, let the integer equal A[i];

The problem is my removal for each duplicate takes O(n), so overall it is O(n^2). I did exactly the same thing in Remove Duplicated from Array II problem and got accepted. I do not understand why it is not acceptable here. Could someone explain? Thanks!