![](/img/trans.png)
[英]Java + Count duplicates from int array without using any Collection or another intermediate Array
[英]Removing duplicates from array without using any collection api of java
你能告诉我有下面的数组,我想删除重复但没有使用任何集合api,请告知如何实现这个...
int[][] test = new int[][]{
{1, 1, 2, 2, 3, 4, 5},
{1, 1, 1, 1, 1, 1, 1},
{1, 2, 3, 4, 5, 6, 7},
{1, 2, 1, 1, 1, 1, 1},};
由于您正在处理int数组并且值相对较小,我建议您创建临时boolean
数组,其中源数组中的数字用作索引。 然后你只需要迭代源数组,将true
放到临时数组的适当单元格中。 在下一次迭代中,查看临时数组和true
的元素索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.