```
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
int size = nums.size();
if(size == 0) return 0;
int j = 0;
int i = 1;
int count =1;
while(i<size)
{
if(nums[i]==nums[j] && count==1)
{
nums[++j]=nums[i];
count = 2;
}
else if(nums[i]!=nums[j])
{
nums[++j]=nums[i];
count = 1;
}
++i;
}
return j+1;
}
};
```