删除排序数组中的重复数字1
System.out.println("删除数组中重复元素后数组的长度为:"+a);
}
public static int removeDuplicates(int[] nums) {
int count=0;
if (nums.length==0 ||nums.length==1)
return -1;
else
{
Arrays.sort(nums);
for(int i=0;i<nums.length-1;i++)
{
if(nums[i]!=nums[i+1])
{
nums[count]=nums[i];
count++;
}
else if(nums[i]==nums[i+1])
continue;
if(nums[nums.length-1]!=nums[nums.length-2])
{
nums[count]=nums[nums.length-1];
count++;
}
for(int i=0;i<count;i++)
System.out.println(nums[i]);
return count;
}
}
}