26.删除排序数组中的重复项
作者:互联网
class Solution {
public int removeDuplicates (int[] nums) {
for (int i=0; i<nums.length-1; i++) {
if (nums[i+1] <= nums[i]) {
int j = i + 1;
int k = i + 2;
try {
while (nums[k] <= nums[i]) {
k++;
}
int tmp = nums[j];
nums[j] = nums[k];
nums[k] = tmp;
System.out.println();
} catch (Exception e) {
e.printStackTrace();
}
}
}
for (int i=0; i<nums.length-1; i++) {
if (nums[i+1] <= nums[i]) {
return i+1;
}
}
return nums.length;
}
}
标签:26,nums,int,Solution,数组,removeDuplicates,排序,public 来源: https://www.cnblogs.com/Vingkin/p/13942026.html