Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime c
位操作, 找出数组中的单数, 双数是成对的数, 单数是只有一个数, 如 1 1 2 2 3 3 5 5 4
单数就是4
class Solution { public: int singleNumber(int A[], int n) { int i=0; int single = 0; while(i!=n) { single = single^A[i]; i++; } return single; } };