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