题目:

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?

Related problem: Reverse Integer

Credits:
Special thanks to @ts for adding this problem and creating all test cases.

代码:

  1. class Solution {
  2. public:
  3. uint32_t reverseBits(uint32_t n) {
  4. uint32_t x = ;
  5. int t = ;
  6. while(t--){
  7. x = x*+n%;
  8. n /= ;
  9. }
  10. return x;
  11. }
  12. };

LeetCode 190. Reverse Bits (算32次即可)的更多相关文章

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

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

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

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

  3. [LeetCode] 190. Reverse Bits 翻转二进制位

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

  4. Java for 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(反转比特数)

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

  6. Java [Leetcode 190]Reverse Bits

    题目描述: everse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represente ...

  7. Leetcode 190 Reverse Bits 位运算

    反转二进制 class Solution { public: uint32_t reverseBits(uint32_t n) { uint32_t ans = ; ; i<; ++i,n &g ...

  8. LeetCode 【190. Reverse Bits】

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

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

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

随机推荐

  1. JQuery学习系列篇(二)

    1.事件切换函数 hover([over],out); over鼠标移动到元素上要触发的函数,out鼠标移出元素要触发的函数. 2.togger 如果元素是可见的,切换为隐藏的:如果元素是隐藏的,切换 ...

  2. ThinkPHP5 (路径优化,路由)

    路径:www.tp5.comm/index.php/index/index/index 站点路径/入口文件/模块/控制器/方法 一.绑定模块 public下的php文件,如index.php,内部写 ...

  3. [ios] 如何调用其他app h5界面调用打开app

    参考资料:app唤醒app h5唤醒app 有趣的URL Scheme 被唤起端需要做的工作(demoApp): 1.设置URL Scheme  只是一个app的标识  具体是什么自己定  一个Sch ...

  4. 关于idlf无法输入中文的解决办法

    最近在学习python 但是刚开始写程序的时候发现无法输入中文  上网查发现有不少mac端的IDLF也存在这个问题 导致这个问题的原因可能不唯一 但是大多数原因应该是Mac 系统自带的 Tcl/Tk ...

  5. intell-

    intellect: n.[U, C] the ability to think in a logical way and understand things, especially at an ad ...

  6. linux进程的有效用户ID

    进程的有效用户ID用于文件访问时的权限检查.通常,有效用户ID等于实际用户ID(也就是你登录是的用户ID),有效组ID等于实际组ID. 我们知道每个文件针对不同的user有不同的读.写.执行权限.当执 ...

  7. Eclipse中使用GIT更新项目

    GIT更新项目: 右击项目——Team——Pull:

  8. css——样式的优先级

    样式的优先级 在p中有id,class,标签,行内样式,它们的优先级: 1.id 样式>class样式>标签样式 2.行内样式>内嵌样式>外部样式 强制优先级 比如我希望上面的 ...

  9. snprintf

    snprintf(),函数原型为int snprintf(char *str, size_t size, const char *format, ...).   将可变参数 “…” 按照format的 ...

  10. CSS3属性之text-overflow:ellipsis,指定多行文本中任意一行显示...

    对于text-overflow:ellipsis,文本超出部分显示...,但要实现这个效果,却有一些必备条件,如下: div{ overflow:hidden; white-space:nowrap; ...