```
class Solution {
public:
int removeDuplicates(int A[], int n) {
int p = 0;
if (n == 0) return NULL;
for (int i = 1;i < n ;i++)
{
if (A[p] != A[i])
{
A[p + 1]= A[i];
p++;
}
}
return p + 1;
}
};
```