Python 1-line Solution


  • 0
    D
    class Solution(object):
        def findComplement(self, num):
            """
            :type num: int
            :rtype: int
            """
            return int(bin(num)[2:].replace('0', '$').replace('1', '0').replace('$', '1'), 2)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.