class Solution {
public:
int removeDuplicates(vector<int>& nums) {
int size=nums.size();
if(size==0) return 0;
int fast=1,slow=1;
while(fast<size){
if(nums[fast]!=nums[fast-1]){
nums[slow]=nums[fast];
slow++;
}
fast++;
}
return slow;
}
};
双指针算法