class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
ans = 0
for i in range(32):
cur_sum = sum([(num >> i) & 1 for num in nums])
if cur_sum % 3:
if i != 31:
ans += (1 << i)
else:
ans -= (1 << i)
return ans