public class Solution {
public int removeDuplicates(int[] nums) {
if(nums==null || nums.length==0)
return0;
int first=1;
int second=1;
int count=1;
int tem=nums[0];
for(;first<nums.length;){
if(nums[first]==tem){
count++;
}else{
tem=nums[first];
count=1;
}
if(count>2){
first++;
}else{
nums[second]=nums[first];
first++;
second++;
}
}
returnsecond;
}
}