题解 | #数组中只出现一次的数(其它数出现k次)#

数组中只出现一次的数(其它数出现k次)

http://www.nowcoder.com/practice/5d3d74c3bf7f4e368e03096bb8857871

python只能调用ctypes来做吹了位运算的结果了

class Solution:
    def foundOnceNumber(self , arr , k ):
        # write code here
        res = 0
        for i in range(32):
            cur = 0
            for t in arr:
                cur += (t >> i) & 1
            res ^= (cur % k) << i
        import ctypes
        return ctypes.c_int(res).value
全部评论

相关推荐

点赞 评论 收藏
分享
Gaynes:查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务