```
public int removeDuplicates(int[] nums)
{
if(nums == null)
return 0;
if(nums.length <= 1)
return nums.length;
int len = 1;
int unique = 0;
for(int i = 1; i < nums.length; i++)
{
if(nums[i] != nums[unique])
{
len++;
nums[len-1] = nums[i];
unique = i;
}
}
return len;
}
```