One line 35ms python solution


  • 0
    C
    class Solution(object):
        def findComplement(self, num):
            """
            :type num: int
            :rtype: int
            """
            return num ^ int('1' * (len(bin(num)) - 2), base=2)
    

Log in to reply
 

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