LeetCode OJ:Reverse Bits(旋转bit位)
Reverse bits of a given 32 bits unsigned integer.
For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as00111001011110000010100101000000).
注意应该做到平台无关性,需要做到这样的话应该声明一个uint32量然后一直向左移,知道得到 0 就可以得到uint32的位数大小 :
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t result = ;
for(uint32_t i = ; i != ; i <<= ){
result <<= ;
result |= (n & );
n >>= ;
}
return result;
}
};
LeetCode OJ:Reverse Bits(旋转bit位)的更多相关文章
- LeetCode 190. Reverse Bits (反转位)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- [LeetCode] 190. Reverse Bits 颠倒二进制位
Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 ...
- [LeetCode] 190. Reverse Bits 翻转二进制位
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- leetcode:Reverse Bits
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- 【leetcode】Reverse Bits(middle)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- Java for LeetCode 190 Reverse Bits
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- Leetcode 190. Reverse Bits(反转比特数)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- LeetCode 190. Reverse Bits (算32次即可)
题目: 190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432 ...
- Leetcode 190 Reverse Bits 位运算
反转二进制 class Solution { public: uint32_t reverseBits(uint32_t n) { uint32_t ans = ; ; i<; ++i,n &g ...
- Java [Leetcode 190]Reverse Bits
题目描述: everse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represente ...
随机推荐
- HTTP服务器(3)
功能完整的HTTP服务器 导语 这个一个功能完备的HTTP服务器.它可以提供一个完整的文档输,包括图像,applet,HTML文件,文本文件.它与SingleFileHttpServer非常相似,只不 ...
- java中内存泄露和内存溢出
内存溢出 out of memory,是指程序在申请内存时,没有足够的内存空间供其使用,出现out of memory:比如申请了一个integer,但给它存了long才能存下的数,那就是内存溢出. ...
- c++ 中 BOOL与bool TRUE与true FALSE与false 区别
转自:http://blog.chinaunix.net/uid-28458801-id-3941112.html FALSE/TRUE与false/true的区别 1.FALSE/TRUE与fa ...
- 前端学习之NaN浅析
在学习Java集合的时候遇到了Float.isNaN(float)函数,点进去一看就不理解了,函数实现如下: public static boolean isNaN(float v) { return ...
- CSS 图像拼合技术
CSS 图像拼合技术 一.图像拼合 图像拼合就是单个图像的集合. 有许多图像的网页可能需要很长的时间来加载和生成多个服务器的请求. 使用图像拼合会降低服务器的请求数量,并节省带宽. 二.图像拼合 - ...
- CSS Fonts(字体)
CSS Fonts(字体) 一.serif和sans-serif字体之间的区别 注意: 在计算机屏幕上,sans-serif字体被认为是比serif字体容易阅读. 二.CSS字型 在CSS中,有两种类 ...
- mapper的namespace
一般情况下mapper的namespace能随便写,不重复即可, 但如果希望使用mybatis动态代理的接口,就需要namespace中的值和需要对应的Mapper(dao)接口的全路径一致.例如:c ...
- LeetCode——Integer Break
Question Given a positive integer n, break it into the sum of at least two positive integers and max ...
- codeforces781C Underground Lab
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...
- Session存储
session其实分为服务器端Session和客户端Session. 当用户首次与Web服务器建立连接的时候,服务器会给用户分发一个sessionid作为标识.用户每次提交页面,浏览器都会把这个ses ...