simply use dictionary (mine init in o(n) but you can do it on demand inside the for loop)
then run on array and dell who happen twice
def singleNumber(self, A): d=dict.fromkeys(A,0) for i in A: d[i] += 1 if (d[i] == 2): del d[i] return int(list(d)[0])