Python one-liner, brute-force


  • 0
    B

    Just calculate the result one number by one number

    return sum([abs(1-int(c)) * 2 ** i for i, c in enumerate(bin(num)[2:][::-1])])
    

Log in to reply
 

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