137.只出现一次的数字II
class Solution {
public int singleNumber(int[] nums) {
Map<Integer,Integer> map = new HashMap<>();
for(int num : nums){
Integer count = map.get(num);
if(count == null){
count = 1;
}else{
++count;
}
map.put(num,count);
}
for(Integer val:map.keySet())
{
if(map.get(val) == 1){
return val;
}
}
return 0;
}
}