Liupeng
Jun 13, 2020
删除排序数组中的重复项 II
Title
MyCode
int removeDuplicates(vector<int>& nums) {
int n = nums.size();
if(n <= 2)
{
return n;
}
int sp = 1;
for(int fp = 2; fp < n; fp++)
{
if(nums[fp] != nums[sp - 1])
{
nums[++sp] = nums[fp];
}
}
return sp + 1;
}