Single Number

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

和上一题比这题就是渣。

class Solution {
public:
    int singleNumber(int A[], int n) {
        if(A == NULL)return 0;
        int re = 0;
        for(int i = 0 ; i < n ;i++)re ^= A[i];
        return re;
    }
};

  

原文地址:https://www.cnblogs.com/pengyu2003/p/3627089.html