My two pointers solution with O(n) time+ O(1) space.

The idea is to user 2 pointers. j finds out each different element it meets. i record the insert position of the next different element and eventually it records the length of the new Array without duplicate.

This is accepted. Just want to know is there any better algorithms or thoughts.

```
public class Solution {
public int removeDuplicates(int[] A) {
if(A.length<=1)return A.length;
int i = 0;
int j = 0;
int cur = A[j];
while(j<A.length){
if(A[j]!=cur){
cur = A[j];
A[i+1] = cur;
i++;
}
j++;
}
return i+1;
}
}
```