1 line python


  • 1
    class Solution(object):
        def findComplement(self, num):
            """
            :type num: int
            :rtype: int
            """
            return 2 ** (len(bin(num)) - 2) - num - 1
    

    it is very slow.


Log in to reply
 

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