题目描述:

everse bits of a given 32 bits unsigned integer.

For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as00111001011110000010100101000000).

解题思路:

移位操作。

代码如下:

public class Solution {
// you need treat n as an unsigned value
public int reverseBits(int n) {
int res = 0;
for(int i = 0; i < 32; i++){
res += n & 1;
if(i < 31)
res <<= 1;
n >>>= 1;
}
return res;
}
}

  

最新文章

  1. 【腾讯bugly干货】QQ空间直播秒开优化实践
  2. linux 学习之路
  3. Socket编程基础知识
  4. mono for android代码记录1 WebClient Post数据到Nopcommerce(post数据到MVC5)
  5. 移动端H5---页面适配问题详谈(一)
  6. WinForm点击按钮,访问百度
  7. 深入浅出:Linux设备驱动之字符设备驱
  8. java 调用 .net webservice
  9. Ye.云狐J2刷机笔记 | 完美切换内部存储卡和SD卡的改法.vold.fstab
  10. 单片微机原理P0:80C51结构原理
  11. jquery append 动态添加的元素事件on 不起作用问题的解决
  12. [iOS]C语言技术视频-09-枚举的定义
  13. BZOJ2287 消失之物
  14. Linux文件系统的目录结构详解
  15. Tesseract训练
  16. 个人经验~mongo故障处理思路
  17. Vue keep-alive总结
  18. 特别翔实的adaboost分类算法讲解 转的
  19. Java程序员职业规划
  20. osm2pgsql windows “illegal option -W” error

热门文章

  1. ts 使用Visual Studio2012和TFS网站管理源代码
  2. WinForm点击按钮在对应的panel里画图
  3. EBP的妙用[无法使用ESP定律时]
  4. 浅析白盒审计中的字符编码及SQL注入
  5. Guava文档翻译之 Guava简介
  6. httpclient 人人网
  7. jstl if条件判断字符串代码
  8. jsp自定义标签分析
  9. Installing Lua in Mac
  10. [STL]算法的泛化过程