Python string manipulation version, I feel like I cheated


  • 0
    E

    class Solution(object):
    def findComplement(self, num):
    """
    :type num: int
    :rtype: int
    """
    return int(bin(num).replace('0b','').replace('1','l').replace('0','o').replace('l','0').replace('o','1'),base=2)


Log in to reply
 

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