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 as00111001011110000010100101000000).
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t tmp =;
uint32_t remainder = ;
int cnt =;
while(n) {
remainder = n%;
tmp = tmp* +remainder;
n /= ;
++cnt;
}
cnt = - cnt;
while(cnt) {
tmp *=;
--cnt;
}
return tmp;
}
};
Reverse Bits的更多相关文章
- [LeetCode] Reverse Bits 翻转位
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- Leetcode-190 Reverse Bits
#190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432615 ...
- 【leetcode】Reverse Bits(middle)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- LeetCode 【190. Reverse Bits】
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- [leetcode] Reverse Bits
Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (re ...
- Java for LeetCode 190 Reverse Bits
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- 190. 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
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
随机推荐
- Asp.net生成静态网页的实现代码
现在做程序都要将动态的页面转换成静态页面,今天教大家在ASP.NET 中实现静态页面的生成方法. using System; using System.Data; using System.Con ...
- bootstrap学习笔记(6)
滚动监听 滚动监听有两种方式: (1)通过属性控制 向想要滚动监听的元素添加如下属性data-spy="scroll",然后添加data- ...
- iis到w3wp的数据流及工作原理
HTTP.sys->IO线程-CLR线程池中的worker线程处理 IO线程只负责把请求交给Worker线程或者放入进程池级别的队列,然后又去HTTP.SYS的队列中处理其它的请求
- ExecutorService常用方法和newFixedThreadPool创建固定大小的线程池
1.ExecutorService: 是一个接口,继承了Executor: public interface ExecutorService extends Executor { } 2.Execut ...
- Html==>>一些经典
1.CSS overflow 属性 2.<input>标签 <input> 标签用于搜集用户信息. 1 type属性 根据不同的 type 属性值,输入字段拥有很多种形式.可以 ...
- Cache&Session Viewer
用于查看和删除网站Cache https://github.com/sdf333/Aspy
- Selenium&EmguCV实现爬虫图片识别
概述 爬虫需要抓取网站价格,与一般抓取网页区别的是抓取内容是通过AJAX加载,并且价格是通过CSS背景图片显示的. 每一个数字对应一个样式,如'p_h57_5' .p_h57_5 { backgrou ...
- Echarts图表控件使用总结2(Line,Bar)—问题篇
Echarts图表控件使用总结1(Line,Bar):http://www.cnblogs.com/hanyinglong/p/Echarts.html 1.前言 a.前两天简单写了一篇在MVC中如何 ...
- A除以B问题
描述:本题要求计算A/B,其中A是不超过1000位的正整数,B是1位正整数.你需要输出商数Q和余数R,使得A = B * Q + R成立. 输入:输入在1行中依次给出A和B,中间以1空格分隔. 输出: ...
- 链接错误——无法解析的外部符号 ConvertStringToBST
今天做COM组件时,编译之后,出现了一个数个编译错误:error LNK2019: 无法解析的外部符号 "wchar_t * __stdcall _com_util::ConvertStri ...