Single Number

Question

Given 2*n + 1 numbers, every numbers occurs twice except one, find it.

Thoughts

^ operation

Solution

class Solution:
    """
    @param A : an integer array
    @return : a integer
    """
    def singleNumber(self, A):
        # write your code here
        result = 0
        for i in A: 
            result = result ^ i
        return results