Skip to content
小飞侠
  • 首页
  • 小程序
  • uniapp
  • vue
  • APICloud
  • 其他
菜单

博客

  1. 首页>
  2. python>
  3. 只出现一次的数字II-位运算137-python

只出现一次的数字II-位运算137-python

  • Post author:xfxia
  • Post published:2023年4月16日
  • Post category:python

python

class Solution:
    def singleNumber(self, nums: List[int]):
        res = 0

        for i in range(32):
            count = 0
            for num in nums:
                count += (num >> i) & 1
            
            if count % 3 != 0:
                res += pow(2, i)
        
        return res if (res>>31) & 1 == 0 else -((res^0xffffffff)+1)

版权声明:本文为VaccyZhu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/VaccyZhu/article/details/120115978

你可能也喜欢

jenkins的api调用python篇(三)秀代码

刷题系列之Python基础

Python解释器介绍与分类

Python从入门到精通十二章问题

python学习笔记(三)

Python项目:打印指定的月份的日历

Leetcode 86. 分隔链表(Python3)

python字母计数-使用Python对文档单词进行计数

Python接口自动化-requests模块之post请求

python frame用法_Pandas Series.to_frame()用法介绍

一种解决Python2中文字符编码问题的办法(个人备忘)

Python员工离职数据分析

python中reduce函数用法_一文读懂reduce函数

python打印n位数“水仙花数”

Python–file 的with用法

用Python怎么多赚钱?6种办法用上 让你过上挣钱的好日子

Python干货-Numpy浅拷贝与深拷贝

python解LeetCode 27. 移除元素

python rabbitmq callback 传参数_python – 操作RabbitMQ

python from pyecharts import Bar报错问题

目录

  • APICloud (3)
  • golang (45)
  • java (1,928)
  • linux (804)
  • mysql (603)
  • php (200)
  • python (1,109)
  • solidity (5)
  • uniapp (59)
  • vue (516)
  • 其他 (18,837)
  • 小程序 (197)

文章归档

  • 2023年八月 (1864)
  • 2023年七月 (14793)
  • 2023年六月 (1)
  • 2023年五月 (2186)
  • 2023年四月 (3838)
  • 2023年三月 (1544)
  • 2023年二月 (3)
  • 2023年一月 (4)
  • 2022年十二月 (3)
  • 2022年十一月 (36)
  • 2022年十月 (16)
  • 2022年九月 (8)
  • 2021年九月 (1)
  • 2020年九月 (6)
  • 2020年八月 (5)

标签

Aave (1) cosmos (6) defi (60) flag (7) gitee (1) github (1) golang (51) java (1926) linux命令 (19) List (1) map (229) mysql (666) npm (47) tendermint (6) uuid (12) vant (15) vmware (63) 区块链 (21) 合约 (7) 小程序版本更新 (1)
  • 首页
  • 小程序
  • uniapp
  • vue
  • APICloud
  • 其他
Copyright xfxia.com 鲁ICP备19024253号-2
关闭菜单