Leetcode 137. Single Number II
发布时间:2020-12-14 04:37:59 所属栏目:大数据 来源:网络整理
导读:是136题的加强版,这次是每个数重复三次. 重复两次用一个bit记录一下,重复三次就用两个记录.很简单. class Solution(object): def singleNumber(self,nums): """ :type nums: List[int] :rtype: int """ a,b = 0,0 for c in nums: a =(a^c)~ b b =(b^c)~ a re
是136题的加强版,这次是每个数重复三次. 重复两次用一个bit记录一下,重复三次就用两个记录.很简单. class Solution(object): def singleNumber(self,nums): """ :type nums: List[int] :rtype: int """ a,b=0,0 for c in nums: a=(a^c)&~b b=(b^c)&~a return a (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |