package com.coolinkiot.utils;
/**
* @data Administrator
* @data 2020/9/2 0002
*/
public class FindDup {
public static int findDup(int[] arr) {
if (null == arr) {
return -1;
}
int len = arr.length;
int res = 0;
for (int i = 0; i < len; i++) {
res ^= arr[i];
}
for (int i = 1; i < len; i++) {
res ^= i;
}
return res;
}
public static void main(String[] args) {
int[] arr = {1, 3, 4, 2, 5, 3};
System.out.println(findDup(arr));
}
}
网友评论