Skip to content

Commit 04785c8

Browse files
authored
Merge pull request doocs#244 from GodisC00L/master
Added Java solution for 190
2 parents 28be855 + e32dd52 commit 04785c8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class Solution {
2+
// you need treat n as an unsigned value
3+
public int reverseBits(int n) {
4+
int res = 0;
5+
for (int i = 0; i < 31; i++, n>>=1, res<<=1) {
6+
res |= (n&1);
7+
}
8+
res |= (n&1);
9+
return res;
10+
}
11+
}

0 commit comments

Comments
 (0)