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. vim 跳到指定行

    在编辑模式下输入 ngg 或者 nG n为指定的行数(如25) 25gg或者25G 跳转到第25行. 在命令模式下输入行号n : n 如果想打开文件即跳转 vim +n FileName 查看当然光标 ...

  2. Java EE 在网页输出九九乘法表

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  3. 字段符号FIELD-SYMBOLS

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

  4. xml语法、DTD约束xml、Schema约束xml、DOM解析xml

    今日大纲 1.什么是xml.xml的作用 2.xml的语法 3.DTD约束xml 4.Schema约束xml 5.DOM解析xml 1.什么是xml.xml的作用 1.1.xml介绍 在前面学习的ht ...

  5. PhpStorm的注册码、Key

    下面是PhpStorm的注册码.Key,其license由用户名和License值组成. User name: EMBRACE License key: ===== LICENSE BEGIN === ...

  6. javascript中怎么让一个页面执行多个window.onload?

    我们都知道在javascript中window.onload 只能有一个如果有多个的话后面的会覆盖前面的,今天我们来看看怎么让一个页面执行多个window.onload <script type ...

  7. iOS - OC NSSize 尺寸

    前言 结构体,这个结构体用来表示事物的宽度和高度. typedef CGSize NSSize; struct CGSize { CGFloat width; CGFloat height; }; t ...

  8. SAP 关于标准成本、计划成本、目标成本、实际成本

    SAP 关于标准成本.计划成本.目标成本.实际成本 <A style="MARGIN-RIGHT: 10px" target=_blank data-ext="{v ...

  9. [转载] goroutine背后的系统知识

    原文: http://www.sizeofvoid.net/goroutine-under-the-hood/ 文章写的非常好, 对内部原理解释的非常清楚, 是我喜欢的风格, 感谢作者的精彩文章. = ...

  10. Xpert 调优

    -- 10046 event 可以定义 SQL TRACE 级别 /* || 默认的10046级别跟 SQL TRACE 一样, 另外还有一些级别: || level 1: SQL Tracing | ...