问题描述
Given an array of integers, every element appears twice except for one. Find that single one.
思路:利用0和任何数异或都为该数定理
/**
* @param {number[]} nums
* @return {number}
*/
var singleNumber = function(nums) {
sum=0;
for(var i=0;i<nums.length;i++){
sum^=nums[i];
}
return sum;
};