class Solution {
public:
int removeDuplicates(vector<int>& nums) {
int len = nums.size();
if(len == 0)
return 0;
if(len == 1)
return 1;
int neww = 0;
for(int old = 1; old < len; ++old){
if(nums[neww] != nums[old]){
++neww;
nums[neww] = nums[old];
}
}
return ++neww;
}
};
一定记得要判断len是不是0或者1