Using Bitwise Operator XOR
We know XOR of two numbers (a and b) a^b equals zero if both the numbers are equal.
So the idea is two find the xor of all numbers in an array , numbers which appear twice cancels out while XORing and number which appears once will remain .
Code in Python
class Solution(object): def singleNumber(self, nums): return reduce(lambda x,y:x^y ,nums)
Time Complexity : O(n)
Space Complexity : O(1)