Skip to content

Commit

Permalink
add day 4
Browse files Browse the repository at this point in the history
  • Loading branch information
ravaan committed May 4, 2020
1 parent 1388888 commit cc07ba0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 04-NumberComplement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Solution {
public int findComplement(int num) {
int bits = (int) (Math.log(num) / Math.log(2) + 1);
for (int i = 0; i < bits; i++)
num = (num ^ (1 << i));
return num;
}
}

0 comments on commit cc07ba0

Please sign in to comment.