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

posted @ 2018-05-03 22:21  kkkkkksssss  阅读(95)  评论(0编辑  收藏  举报