LeetCode476.数字的补数
class Solution:
def findComplement(self, num):
"""
:type num: int
:rtype: int
"""
binaryX = bin(num)[2:]
binaryX = int(binaryX,2) ^ int("1"*len(binaryX),2)
return binaryX
class Solution:
def findComplement(self, num):
"""
:type num: int
:rtype: int
"""
binaryX = bin(num)[2:]
binaryX = int(binaryX,2) ^ int("1"*len(binaryX),2)
return binaryX