Given an array of integers, every element appears twice except for one. Find that single one.
思路:
1. 使用HASH表存储每个数组元素出现的次数
2. 理解按位异或操作的本质原理
int singleNumber(int* nums, int numsSize) {
int result = 0;
int i = 0;
for (i = 0; i < numsSize; i ++){
result ^= nums[i];
}
return result;
}
采用位操作的方式比较精炼。