[leetcode] Reverse Bits
2024-10-10 16:07:36
Reverse Bits
Reverse bits of a given 32 bits unsigned integer.
For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110000010100101000000).
Follow up:
If this function is called many times, how would you optimize it?
Related problem: Reverse Integer
Credits:
Special thanks to @ts for adding this problem and creating all test cases.
Special thanks to @ts for adding this problem and creating all test cases.
class Solution
{
public:
uint32_t reverseBits(uint32_t n)
{
int A[] = {};
int i = ;
while(n > )
{
A[i++] = n % ;
n /= ;
} int sum = ;
for(i = ; i < ; i++)
sum = sum * + A[i]; return sum;
}
};
最新文章
- Mysql学习笔记(四)聊聊数据库索引
- 架构模式对象与关系结构模式之:标识域(Identity Field)
- oracle 查询当前库中所有表以及某表字段信息
- 解决 Tomcat 无法绑定 80 端口的问题,以及 Tomcat 配置虚拟目录、二级域名等
- 支付宝支付集成,上传RSA公钥一直显示格式错误
- C++ vector和list的区别
- hdu 4635	Strongly connected(强连通)
- 接入新浪、腾讯微博和人人网的Android客户端实例 接入新浪、腾讯微博和人人网的Android客户端实例
- plsql中文乱码问题(显示问号)
- js 发送ajax请求(XMLHttpRequest)
- 奔五的人,准备学习iOS开发
- ORA-01940无法删除当前已连接用户
- VS2010 C#调用C++ DLL文件
- Linux基础学习笔记以及常用命令
- iozone测试磁盘性能
- python中两种方法实现二分法查找,细致分析二分法查找算法
- ionic2中使用datetime组件如何默认设置当前时间?
- Kali学习笔记26:OWASP_ZAP
- 面试知识点——Java
- 面试小结之Elasticsearch篇(转)
热门文章
- 未能找到类型或命名空间名称“Coco”(是否缺少 using 指令或程序集引用)
- ionic 添加应用图标与启动页
- bootstrap插件学习-bootstrap.button.js
- 受限玻尔兹曼机(RBM)学习笔记(五)梯度计算公式
- Device.js – 快速检测平台、操作系统和方向信息
- EL表达式经典用法
- ChartDirector应用笔记(二)
- c#通用递归生成无限层级树
- 【Unity】12.5 Navmesh Obstacle组件
- LeetCode129:Sum Root to Leaf Numbers