# LeetCodeOJ_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).
If this function is called many times, how would you optimize it?

Related problem Reverse Integer
Tags Bit Manipulation
Similar Problems (E) Number of 1 Bits

## 代码：

class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t m=0;
for(int i=0;i<32;i++)
{
m=m*2+n%2;
n=n/2;
}
return m;
}
};

• 本文已收录于以下专栏：

## 190. Reverse Bits\331. Verify Preorder Serialization of a Binary Tree

Reverse Bits description implementation Verify Preorder Serialization of a Binary Tree description i...

## LeetCodeOJ--Reverse Words in a String(python版本)

Given an input string, reverse the string word by word. For example, Given s = "the sky is blue"...

## 字节的按位逆序 Reverse Bits

http://www.hookcn.org/2011/01/reverse-bits.html   源自某公司的一道试题，问题很简单： 输入一个字节（8 bits），将其按位反序。 也就是说如...

## Leetcode - Reverse Bits

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

## [LeetCode]Reverse Bits

QuestionReverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represen...
• byamao1
• 2016年12月13日 20:15
• 89

举报原因： 您举报文章：LeetCodeOJ_190_Reverse Bits 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)