一、题目
二、代码
class Solution
{
public int removeDuplicates(int[] nums)
{
int i=2;
int length = nums.length;
int first = 2;
int second = 1;
int third = 0;
first = nums[0];
while(i<length)
{
first = i;
if(nums[first] == nums[second]&& nums[second] == nums[third])
{
nums[third] = -10003;
}
third = second;
second = first;
i++;
}
int count = 0;
int index= 0;
for(i=0;i<length;i++)
{
if(nums[i]== - 10003) continue;
else
{
nums[index++] = nums[i];
count++;
}
}
return count;
}
}