```
public int removeDuplicates(int[] nums) {
if(nums == null) return 0;
if(nums.length ==0||nums.length ==1) return nums.length;
int curr = 0, start = 0;
for(; curr < nums.length-1; ++curr){
if(nums[curr] != nums[curr+1]) {
if(start != curr) nums[++start] = nums[curr +1];
else ++start;
}
}
return start== curr? nums.length : ++ start;
}
```