[leetcode] Reverse Bits
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
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;
}
};
[leetcode] Reverse Bits的更多相关文章
- 2016.5.16——leetcode:Reverse Bits(超详细讲解)
leetcode:Reverse Bits 本题目收获 移位(<< >>), 或(|),与(&)计算的妙用 题目: Reverse bits of a given 3 ...
- [LeetCode] Reverse Bits 翻转位
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- leetcode reverse bits python
Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (re ...
- LeetCode Reverse Bits 反置位值
题意:给定一个无符号32位整数,将其二进制形式左右反置,再以整型返回. 思路:循环32轮,将n往右挤出一位就补到ans的尾巴上. class Solution { public: uint32_t r ...
- [LeetCode] Reverse Bits 位操作
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- lc面试准备:Reverse Bits
1 题目 Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represente ...
- LeetCode 190. Reverse Bits (反转位)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- 【一天一道Leetcode】#190.Reverse Bits
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 我的个人博客已创建,欢迎大家持续关注! 一天一道le ...
- [LeetCode] 190. Reverse Bits 颠倒二进制位
Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 ...
随机推荐
- 【cs229-Lecture18】线性二次型调节控制
本节内容: 控制MDP的算法: 状态行动奖励: 非线性动力学系统: 模型: LQR:线性二次型调节控制:(Riccati方程)
- 【转载】关于 Ubuntu 的小知识分享
转载自:http://os.51cto.com/art/201307/402197.htm 一.默认开机直接进入到Ubuntu命令行界面 安装Ubuntu后,开机会默认进入到图形界面,如果不喜欢图形界 ...
- LoopBack – 开源的,可扩展的 Node.js 框架
LoopBack 是建立在 Express 基础上的开源 Node.js 框架,专门为 Mobile,Web 和其他设备做了优化.LoopBack 能够连接到多个数据源,使用 Node.js 编写业务 ...
- ActiveMQ学习(二)——MQ的工作原理
如图所示 首先来看本地通讯的情况,应用程序A和应用程序B运行于同一系统A,它们之间可以借助消息队列技术进行彼此的通讯:应用程序A向队列1发送一条信息,而当应用程序B需要时就可以得到该信息. 其次是远程 ...
- 餐厅到店点餐系统(APP)
MY-HR 成员: 角色分配 学号 博客园 丘惠敏 PM项目经理 201406114203 http://www.cnblogs.com/qiuhuimin/ 郭明茵 用户 201406114204 ...
- hibernate用注解(annotation)配置sequence
@Id@SequenceGenerator(name="sequenceGenerator",sequenceName="ACTIVITIESSCOPE_SEQ" ...
- 译:重置/还原Windows IIs设置为默认设置
译文出处:http://www.codeproject.com/Tips/870858/Reset-Restore-IIS-Settings-to-its-Default-in-Windo 简介: I ...
- 关于window.onload,window.onbeforeload与window.onunload
★ window.onload 当页面加载完毕的时候执行,即在当前页面进行其他操作之前执行.如,刚进入某个网页的弹窗提示. ( 与window.onload相近的可以参考我写的另外一篇记录&qu ...
- c#开发工具软件集合
visual studio 2015(自带Nuget) Resharper de4dot dnspy ILMergeGui Git 大漠插件3.1233 天使插件v4.019 Navicat_Prem ...
- C# Web Forms - Using jQuery FullCalendar
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> ...