136. Single Number

Given an array of integers, every element appears twice except for one. Find that single one.

Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

0和2个相同的数异或等于0  

1 int singleNumber(int* nums, int numsSize) {
2     int flag = 0;
3     int i;
4     for(i = 0; i < numsSize; i++)
5         flag ^= nums[i];
6     return flag;
7 }
原文地址:https://www.cnblogs.com/boluo007/p/5495941.html