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. How to: Update an .edmx File when the Database Changes

    https://msdn.microsoft.com/en-us/library/cc716697.aspx In the Model Browser, right-click the .edmx f ...

  2. PHPwebshell分析

    这几天已知在做webshell的检测,JSP的不说了,特征检测起来很好匹配到,而且全是一家亲,互相模仿的居多. 今天看了一篇文章,看到14年蘑菇的webshell的后门然后很不错. ========= ...

  3. 程序间数据共享与传递:EXPORT/IMPORT、SAP/ABAP Memory

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  4. ABAP DESCRIBE语句

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  5. 键盘unicode值对照表

    A:65 B:66 C:67 D:68 E:69 F:70 G:71 H:72 I:73 J:74 K:75 L:76 M:77 N:78 O:79 P:80 Q:81 R:82 S:83 T:84 ...

  6. HDU 1728 逃离迷宫

    [题目描述 - Problem Description] 给定一个m × n (m行, n列)的迷宫,迷宫中有两个位置,gloria想从迷宫的一个位置走到另外一个位置,当然迷宫中有些地方是空地,glo ...

  7. Object-C中的排序和Compare陷阱

    来源:http://m.blog.csdn.net/blog/u011883764/38868097 Date : 2015-12-24 一.Compare陷阱 NSString有多个compare相 ...

  8. Zeller公式推导及C#代码示例(待完善)

    Zeller公式用于计算给定日期是星期几. 该方法可以用数论知识进行证明. 假设给定日期Date为Year-Month-Day,求解该日期是星期几的问题实际上就是以之前某个确定星期几的日期作为参考点, ...

  9. js之oop <一> 创建对象,构造器(class)

    js中除了基本类型,就是对象.可以说在js中处处皆对象. 由于js是弱语言,在编写的过程中很容易混淆 object 和 class 也就是对象和构造器. object(对象):一般对象都由var关键字 ...

  10. bootstrap学习笔记<四>(table表格)

    表格 bootstrap为table表格定制多个常用样式:基本样式,隔行变色样式,带边框样式,荧光棒样式,紧凑样式,响应样式. ☑  .table:基础表格 ☑  .table-striped:斑马线 ...