Python | Leetcode Python题解之第137题只出现一次的数字II

作者 : admin 本文共111个字,预计阅读时间需要1分钟 发布时间: 2024-06-9 共2人阅读

题目:

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
本站无任何商业行为
个人在线分享 » Python | Leetcode Python题解之第137题只出现一次的数字II
E-->