```
//One Pass!!
public class Solution {
public int removeDuplicates(int[] nums) {
int start = 1, count = 1;
if(nums.length < 3) return nums.length;
for(int i = 1; i < nums.length; i++){
if(nums[i] == nums[i-1]){
count++;
if(count < 3) nums[start++] = nums[i];
}else{
count = 1;
nums[start++] = nums[i];
}
}
return start;
}
}
```