题解 | #数组中只出现一次的两个数字#
数组中只出现一次的两个数字
http://www.nowcoder.com/practice/389fc1c3d3be4479a154f63f495abff8
class Solution: def FindNumsAppearOnce(self , array ): #1)用位运算的方法: xor=0 for i in array: xor=xor^i flag=1 while((xor&flag)==0): flag=flag<<1 res=0 res2=0 #分组进行异或操作--分治思想: for i in array: if i&flag: res=res^i else: res2=res2^i if res<res2: return [res,res2] else: return [res2,res] # write code here