Skip to content

Commit

Permalink
Merge pull request #244 from GodisC00L/master
Browse files Browse the repository at this point in the history
Added Java solution for 190
  • Loading branch information
yanglbme authored Jan 19, 2020
2 parents 28be855 + e32dd52 commit 04785c8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions solution/0190.Reverse Bits/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Solution {
// you need treat n as an unsigned value
public int reverseBits(int n) {
int res = 0;
for (int i = 0; i < 31; i++, n>>=1, res<<=1) {
res |= (n&1);
}
res |= (n&1);
return res;
}
}

0 comments on commit 04785c8

Please sign in to comment.