```
public class Solution {
public int removeDuplicates(int[] nums) {
if(nums.length <= 1){
return nums.length;
}
int tmp = nums[0];
int length = 1;
for(int i = 1; i < nums.length; i++){
if(tmp != nums[i]){
tmp = nums[i];
nums[length] = nums[i];
length++;
}
}
return length;
}
}
```