Single Number II Posted on 2018-09-02 Descriptionhttps://leetcode.com/problems/single-number-ii/description/ Solution12345678910111213141516171819202122class Solution: def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ ret = 0 count = 0 for item in nums: count += ( (item >> 31) & 1 ) neg = count % 3 for position in range(32): count = 0 for item in nums: count += ( (item >> position) & 1 ) ret += (2 ** position) * ( (count % 3 + neg) % 2 ) if neg: return -( ret + 1 ) return ret