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 -- 按位反转的更多相关文章

  1. Reverse bits - 按位反转一个int型数字

    Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...

  2. LeetCode 190. Reverse Bits (算32次即可)

    题目: 190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432 ...

  3. Leetcode 190. Reverse Bits(反转比特数)

    Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...

  4. LeetCode 190. Reverse Bits (反转位)

    Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...

  5. 【一天一道Leetcode】#190.Reverse Bits

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 我的个人博客已创建,欢迎大家持续关注! 一天一道le ...

  6. [LeetCode] 190. Reverse Bits 颠倒二进制位

    Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 ...

  7. 190. Reverse Bits

    题目: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented ...

  8. 【LeetCode】190. Reverse Bits

    题目: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented ...

  9. [leet code 190]reverse bits

    1 题目 Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represente ...

随机推荐

  1. shell脚本批量ping测试IP是否通

    #!/bin/bash rm -f result.txt cat ip.txt | fping > result.txt 2行代码就搞定,很方便,初学shell,很强大,问了下同事,但是shel ...

  2. JAVA排序--[选择排序]

    package com.array; public class Sort_Select { /** * 项目名称:选择排序 ; * 项目要求:用JAVA对数组进行排序,并运用选择排序算法; * 作者: ...

  3. Mybatis+struts2+spring整合

    把student项目改造成ssm  struts2 +mybatis+spring 1,先添加spring支持:类库三个,applicationContext.xml写在webinf下四个命名空间,监 ...

  4. CUBRID学习笔记23 关键字列表

    先放上特殊的字符 Backtick Symbol - `    反引号 同撇 Double Quotes - "      双引号 Square Brackets - [  中括号 如    ...

  5. ubuntu14.04换一个更快的源

    mirrors.yun-idc.com,这个源可比ubuntu自带的源快多了,我的source.list文件内容如下: deb http://mirrors.yun-idc.com/ubuntu/ t ...

  6. ORACLE数据库DBMS_JOB的创建与使用

    http://my.oschina.net/u/2309120/blog/371437 创建 DBMS_JOB 使用以下语句: VARIABLE jobno number;begin DBMS_JOB ...

  7. Android 中Service生命周期

    使用context.startService() 启动Service 其生命周期为context.startService() ->onCreate()- >onStart()->S ...

  8. PHP SPL标准库之SplFixedArray使用实例

    SplFixedArray主要是处理数组相关的主要功能,与普通php array不同的是,它是固定长度的,且以数字为键名的数组,优势就是比普通的数组处理更快. 看看我本机的Benchmark测试: i ...

  9. BigDecimal类型比较大小

    这个类是java里精确计算的类 1 比较对象是否相等     一般的对象用equals,但是BigDecimal比较特殊,举个例子:     BigDecimal a=BigDecimal.value ...

  10. 工作流学习——Activiti整体认识二步曲 (zhuan)

    http://blog.csdn.net/zwk626542417/article/details/46594505 ***************************************** ...