classSolution(object):defsingleNumber(self,nums):""" :type nums: List[int] :rtype: int """# "1" appear oncet1=0# "1" appear twicet2=0# "1" appear three timest3=0foriinnums:# update t2t2|=t1&i# update t1t1=t1^i# check which bits appear three timest3=(t1&t2)# put those bits to 0t1&=~t3t2&=~t3returnt1