# leetcode 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?

public class BitManipulation {
public static int reverseBit(int n){
int res=0;
for(int i=0;i<32;i++){
if((n&1)==1){
res=(res<<1)+1;
n=n>>1;
}else{
res=res<<1;
n=n>>1;
}
}
return res;
}
public static void main(String[] args){
int n=43261596 ;
int res=reverse(n);
System.out.println("result:"+res);
}
}

#### LeetCode(190) Reverse Bits

2015-03-22 12:46:11

#### 【LeetCode-190】 Reverse Bits(C++)

2016-05-20 23:11:28

#### LeetCode 190. Reverse Bits 题解

2017-03-02 11:09:44

#### LEETCODE 190

2016-03-11 19:36:13

#### LeetCode 第 190 题 (Reverse Bits)

2016-04-18 21:31:15

#### 190. Reverse Bits [easy] (Python)

2016-06-18 11:04:11

#### [LeetCode: Python]190. Reverse Bits

2017-05-12 12:14:22

#### Leetcode: 190. Reverse Bits(JAVA)

2016-03-13 11:18:49

#### 【LeetCode-面试算法经典-Java实现】【190-Reverse Bits（反转二制）】

2015-08-24 07:15:15

#### 【LeetCode】Reverse Bits 翻转二进制

2015-04-23 14:59:36