190. 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?
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t ret=;
for(int i=; i<; i++) {
ret = (ret*) + (n & 0x1);
n /= ;
}
return ret;
}
};
190. Reverse Bits -- 按位反转的更多相关文章
- Reverse bits - 按位反转一个int型数字
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- LeetCode 190. Reverse Bits (算32次即可)
题目: 190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432 ...
- Leetcode 190. Reverse Bits(反转比特数)
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】#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 ...
- 190. Reverse Bits
题目: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented ...
- 【LeetCode】190. Reverse Bits
题目: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented ...
- [leet code 190]reverse bits
1 题目 Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represente ...
随机推荐
- Task<TResult>的使用
https://msdn.microsoft.com/en-us/library/dd321424(v=vs.110).aspx Represents an asynchronous operatio ...
- c#扩展方法的理解(二:接口)
namespace ExtensionInterfaceMethod { class Program { static void Main(string[] args) { //使用接口变量来调用扩展 ...
- 用Spring MVC开发简单的Web应用
这个例子是来自于Gary Mak等人写的Spring攻略(第二版)第八章Spring @MVC中的一个例子,在此以学习为目的进行记录. 问题:想用Spring MVC开发一个简单的Web应用, 学习这 ...
- oracle命令识记
连接数据库 sqlplus /nolog; conn / as sysdba; set ORACLE_SID=实例名; 查看表结构命令 select table_name from user_tabl ...
- ubuntu14.04换一个更快的源
mirrors.yun-idc.com,这个源可比ubuntu自带的源快多了,我的source.list文件内容如下: deb http://mirrors.yun-idc.com/ubuntu/ t ...
- MySQL修改约束
添加主键约束: ALTER TABLE tbl_name ADD [CONSTRAINT [symbol索引名]] PRIMARY KEY [index_type] (index_col ...
- 随机步法A-Z
程序是生成一个10X10的字符数组,初始化时全为 ‘.’ 的随机步法.程序必须随机的从一个元素 ‘走到’ 另一个元素,每次只向上.向下.向左或向右移动一个元素位置.已访问过的元素按访问顺序用字母A到 ...
- 汇编语言指令与debug命令符
•MOV与ADD指令 汇编指令 控制CPU完成的操作 形式化语法描述 mov ax, 18 将18送入AX (AX)=18 mov ah, 78 将78送入AH (AH)=78 add ax, 8 ...
- springmvc企业级开发实战
一.用eclipse插件搭建项目 二.pom文件 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi ...
- mysql 中文字段排序( 按拼音首字母排序) 的查询语句
在处理使用Mysql时,数据表采用utf8字符集,使用中发现中文不能直接按照拼音排序 如果数据表tbl的某字段name的字符编码是latin1_swedish_ci select * from `tb ...