自己的写法,不想评价
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;
}
}
原文:https://www.cnblogs.com/Vingkin/p/13942026.html