题目:
Given an array of integers, every element appears twice except for one. Find that single one.
代码:
var singleNumber = function(nums) {
var bool = {};
for(var i in nums){
if(!bool[nums[i]]){
bool[nums[i]]=true;
} else {
bool[nums[i]]=false;
}
}
for(var i in nums){
if(bool[nums[i]]){
return nums[i];
}
}
};