import java.util.*;
public class Main {
public static void main(String[] args) {
int nums[] = {3, 1, 2, 2, 5, 5, 6, 6};
int[] ints = singleNumber(nums);
for (int i = 0; i < ints.length; i++) {
System.out.print(ints[i]);
}
}
public static int[] singleNumber(int[] nums) {
Set<Integer> set = new HashSet<>();
for (int i = 0; i < nums.length; i++) {
if (!set.add(nums[i])) {
set.remove(nums[i]);
}
}
Iterator<Integer> iterator = set.iterator();
ArrayList arrayList = new ArrayList();
while (iterator.hasNext()) {
arrayList.add(iterator.next());
}
int res[] = new int[arrayList.size()];
for (int i = 0; i < arrayList.size(); i++) {
res[i] = (int) arrayList.get(i);
}
return res;
}
}
07-28
100
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)