1. 程式人生 > >leetcode - 476 - 數字的補數

leetcode - 476 - 數字的補數

class Solution:
    def findComplement(self, num):
        """
        :type num: int
        :rtype: int
        """
        m = bin(num)
        m = m[2:]
        n=[str(1-int(i)) for i in m]
        k = "".join(n)
        k = int(k,2)
        
        return k