https://leetcode-cn.com/problems/single-number/
    位运算,用到了异或
    对于异或,需要记住的两大特性
    0 异或任何数都是它本身
    任何数异或它本身等于0

    1. class Solution(object):
    2. def singleNumber(self, nums):
    3. """
    4. :type nums: List[int]
    5. :rtype: int
    6. """
    7. """
    8. 位运算,异或
    9. 0 异或任何数都是它本身
    10. 任何数异或它本身等于0
    11. """
    12. ans = 0
    13. for i in nums:
    14. ans ^= i
    15. return ans