Single Number
Problem: Single Number
This problem is a easier version of Single Number II. We simply use bit manipulation exclusive-or on all the numbers we have. By this operation, we can make reduce same numbers to 0, then what's left is the single number.
Code in Python:
class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
res = 0
for x in nums:
res ^= x
return res