Reverse Bits
来源:互联网 发布:老11选5遗漏数据查询 编辑:程序博客网 时间:2024/05/29 09:30
c++
class Solution {public: uint32_t reverseBits(uint32_t n) { uint32_t res = 0; int cnt = 0; while (cnt++!=32){ res = res << 1; res += (n & 0x01); n = n >> 1; } return res; }};
python
class Solution(object): def reverseBits(self, n): """ :type n: int :rtype: int """ res = ['0']*32 bn = bin(n)[2:] res[-len(bn):] = bn res = res[::-1] return int('0b' + ''.join(res),2)
0 0
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- c链表
- Kotlin
- UML-类图
- oracle自动分区设置
- 进程间通信匿名管道
- Reverse Bits
- 一周stackoverflow热门问题选登:如何用Python for循环实现列表中数据两两循环打印?
- 数据环隔位取数
- Routing in Angular 2 RC.1
- 项目视图组(Item Views)
- Android apk动态加载机制的研究(二):资源加载和activity生命周期管理
- Java教程第一天
- 云主机pppcloud端午节活动,送苹果笔记本,iPhone6s手机,联想笔记本!
- Tomcat中文乱码处理之URIEncoding、useBodyEncodingForURI及CharacterEncodingFilter