Python | Leetcode Python题解之第137题只出现一次的数字II
题目:
题解:
class Solution:
def singleNumber(self, nums: List[int]) -> int:
a = b = 0
for num in nums:
b = ~a & (b ^ num)
a = ~b & (a ^ num)
return b
题目:
题解:
class Solution:
def singleNumber(self, nums: List[int]) -> int:
a = b = 0
for num in nums:
b = ~a & (b ^ num)
a = ~b & (a ^ num)
return b