136. 只出现一次的数字

  1. 题目链接

  2. 解题思路:只出现一次,其余的数全部两次,异或操作,其余两次的数异或之后,全部变成了0.

  3. 代码

    class Solution:
        def singleNumber(self, nums: List[int]) -> int:
            return reduce(lambda x, y : x ^ y, nums)
    
posted @ 2024-12-27 11:27  ouyangxx  阅读(16)  评论(0)    收藏  举报