We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 28be855 + e32dd52 commit 04785c8Copy full SHA for 04785c8
solution/0190.Reverse Bits/Solution.java
@@ -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
9
+ return res;
10
11
+}
0 commit comments