经典android、java面试题之查找重复元素算法;
public static void main(String[] args) {
int[] data = new int[] {11,10,55,79,100,111,45,56,79,90,345,1000};
searchRepeatIndex(data);
}
//去重
public static void searchRepeatIndex(int[] arr){
for (int i = 0; i < arr.length-1; i++) {
for (int j = i+1; j < arr.length; j++) {
if (arr[i]==arr[j]) {
System.out.println("第"+(i+1)+"个元素重复了");
break;//去掉这句可以查找重复次数
}
}
}
}