Single line solution using set


#1
def singleNumber(self, A):
     return sum(set(A))*2-sum(A)

#2

Can you explain the logic?


#3

Every element is repeated twice except one so if we take set of A it has all unique numbers only. Therefore twice the sum of set(A) - sum of A will give that number which is not repeated.