Single Number
Given an array of integers, every element appears twice except for one. Find that single one.
Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
不用bit操作只能做到liner runtime complexity. 没法弄成no extra memory.
class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
dict = {}
for n in nums:
if not dict.pop(n,None):
dict[n] = 1
for k in dict:
return k