leetcode 137. Single Number II 发表于 2018-12-27 | 分类于 leetcode 题目链接:leetcode 思路:使用xor异或的性质可以常数空间复杂度解决问题。 123456789101112class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ ones = twos = threes= 0 for num in nums: ones = (ones ^ num) & ~twos twos = (twos ^ num) & ~ones return onesprint(Solution().singleNumber([1,1,1,2,2,2,3]))