class Solution {

public:

```
int removeDuplicates(vector<int>& nums) {
int size=nums.size();
int i=0,j=0;
while(i<size){
nums[j++]=nums[i];
while(i+2<size && nums[i]==nums[i+1] && nums[i+1]==nums[i+2]){
i++;
}
i++;
}
return j;
}
```

};