算法一个有序且元素重复的数组来进行去重排序流殃2021-05-072024-03-30一个有序数组,比如1 1 2 3 4 5 6 ,要拿到前五个不重复的长度 思路代码实现1234567891011121314151617public static int [] get(int [] res){ if (res.length < 1){ return res; } int i = 0, r = i+1; while (r < res.length){ if (res[i]==res[r]){ r++; continue; } i++; res[i]=res[r]; r++; } int[] ints = Arrays.copyOf(res, i + 1); return ints;}