Given an array of integers, every element appears # twice except for one. Find that single one.
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ xor = 0 for num in nums: xor ^= num return xor x=Solution() print(x.singleNumber([2,5,2,6,7,6,7]))
输出:
5