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?
<span style="font-size:18px;">int singleNumber(int A[], int n)
{
int result = 0;
for(int i = 0;i<n;i++)
result ^= A[i];
return result;
}</span>
偶数个相同的整数异或后为0,所以遍历数组,与所有的数组元素相继异或,最后异或的结果就是单独 的整数
已AC 36ms