Single Number

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

 1 class Solution {
 2 public:
 3     int singleNumber(int A[], int n) {
 4         int num = 0;
 5         for(int i=0;i<n;++i) {
 6             num ^= A[i];
 7         }
 8         return num;
 9     }
10 };

 按位与同一个数两次。

原文地址:https://www.cnblogs.com/ittinybird/p/4431485.html