Skip to content

Commit ad90163

Browse files
committed
reverse_bits
1 parent b49e007 commit ad90163

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Golang solution for leetcode. For each problem, there is a simple *_test.go to t
154154
#### [179. Largest Number](https://github.com/hitzzc/go-leetcode/tree/master/largest_number)
155155
#### [187. Repeated DNA Sequences](https://github.com/hitzzc/go-leetcode/tree/master/repeated_dna_sequences)
156156
#### [189. Rotate Array](https://github.com/hitzzc/go-leetcode/tree/master/rotate_array)
157+
#### [190. Reverse Bits](https://github.com/hitzzc/go-leetcode/tree/master/reverse_bits)
157158

158159

159160

reverse_bits/reverse_bits.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
uint32_t reverseBits(uint32_t n) {
4+
uint32_t ret = 0;
5+
for (int i = 0; i < 32; ++i){
6+
ret = ret*2 + (n&0x1);
7+
n /= 2;
8+
}
9+
return ret;
10+
}
11+
};

0 commit comments

Comments
 (0)