One line Python (little bit tricky)


  • 0

    import math
    class Solution(object):
    def findComplement(self, num):
    return 2**int(math.log(num)/math.log(2) + 1) - num - 1

    Anyway this is my first post in Discuss. :3


Log in to reply
 

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