Skip to content

Commit

Permalink
求补
Browse files Browse the repository at this point in the history
  • Loading branch information
Azureki committed Mar 18, 2019
1 parent d207b3f commit 746e959
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 1012. Complement of Base 10 Integer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from math import log2
class Solution:
def bitwiseComplement(self, N: int) -> int:
if N == 0:
return 1
count = int(log2(N)) + 1
return 2 ** count - N - 1

0 comments on commit 746e959

Please sign in to comment.