好吧,就先当做凑数。
public class Solution {
public int singleNumber(int[] nums) {
Map<Integer, Integer> map = new HashMap<>();
for (int n: nums) {
if (map.containsKey(n)) {
if (map.get(n) == 1) {
map.put(n, 2);
} else {
map.remove(n);
}
} else {
map.put(n, 1);
}
}
Iterator<Integer> iterator = map.keySet().iterator();
return iterator.next();
}
}