Given an array of integers, every element appears twice except for one. Find that single one.
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
Credits To: leetcode.com
Leave me comments, if you have better ways to solve.
## Blog link: https://code.dennyzhang.com/single-number class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ x = 0 for i in nums: x = x ^ i return x if __name__ == '__main__': s = Solution() print s.singleNumber([1, 2, 1]) print s.singleNumber([2, 2, 1])