136. 只出现一次的数字 - 力扣(LeetCode)

大佬图解

代码

python 复制代码
# encoding = utf-8
# 开发者:Alen
# 开发时间: 18:44 
# "Stay hungry,stay foolish."

class Solution(object):
    def singleNumber(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """

        res = 0 # n ^ 0 = n
        for n in nums:
            res = res ^ n
        return res

结果

解题步骤:https://www.bilibili.com/video/BV1AiXrBsEWd/?vd_source=15b4bc8968fa5203cc470cb68ff72c96

相关推荐
mmmmath_31 小时前
LeetCode.028.找出字符串中第一个匹配项的
数据结构·算法·leetcode
Navigator_Z2 小时前
LeetCode //C - 1255. Maximum Score Words Formed by Letters
c语言·算法·leetcode
All for pursuit.2 小时前
【栈-4】739.每日温度
数据结构·c++·算法·leetcode
开开心心就好2 小时前
安卓手写文字生成工具,多种纸张一直免费
网络·网络协议·tcp/ip·leetcode·智能手机·电脑·模拟退火算法
All for pursuit.2 小时前
【栈-5】84.柱状图中最大的矩形
数据结构·c++·算法·leetcode
圣保罗的大教堂3 小时前
leetcode 1665. 完成所有任务的最少初始能量 中等
leetcode
Tisfy18 小时前
LeetCode 3498.字符串的反转度:一次遍历
leetcode·字符串·题解·遍历
a1879272183118 小时前
【算法】树(二):队列与祖先——BFS 骨架三配件、短路透传与合流
算法·leetcode·二叉树··bfs·算法讲解·树遍历
Navigator_Z21 小时前
LeetCode //C - 1254. Number of Closed Islands
c语言·算法·leetcode
0+1111 天前
算法 --二分查找
c++·算法·leetcode