Given an array of integers, every element appearstwiceexcept for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
Answer:
class Solution(object):
def singleNumber(self, nums):
result = 0
for num in nums:
result ^= num#异或运算
return result