<p>
不知道为什么用set是错的,感觉是对的啊</p><div>
</div>
public static int removeDuplicates(int[] nums) {
int len = nums.length;
int count = 0;
for(int i = 1;i<len;i++)
{
if(nums[i]==nums[i-1])
count++;
else
nums[i-count] = nums[i];
}
return len-count;
}
int len = nums.length;
int count = 0;
for(int i = 1;i<len;i++)
{
if(nums[i]!=nums[i-1])
nums[count++] = nums[i];
}
return count;