**

```
public class Solution {
public int removeDuplicates(int[] nums) {
if(nums.length == 0 || nums.length == 1){
return nums.length;
}
int read = 2;
int write = 2;
int count = 1;
while(read < nums.length){
if(nums[read] == nums[read-1]){
if(nums[read] == nums[write-2]){
read++;
}
else{
nums[write] = nums[read];
read++;
write++;
}
}
else{
nums[write] = nums[read];
read++;
write++;
}
}
return write;
}
}
```

**