删除重复元素。修改BinarySearch类中的测试用例来删去排序之后白名单中所有重复元素。
代码
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22public class Main { public static void rank(int[] a, String[] keys, char arg){ int[] whiteList = new int[]{7,1,4,6,5}; Arrays.sort(whiteList); List<Integer> list = new ArrayList<>(); for (int i = 0; i < whiteList.length-1; i ++){ if(whiteList[i] != whiteList[i+1]){ list.add(whiteList[i]); } } Iterator<Integer> iterator= list.iterator(); while (iterator.hasNext()){ System.out.println(iterator.next()); } } public static void main(String[] args) { rank(a, keys, arg); } }
答案
复制代码
1
2
3
4
5
61 4 5 6
返回目录
最后
以上就是魁梧丝袜最近收集整理的关于算法4-1.1.28删除重复元素的全部内容,更多相关算法4-1内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复