Flip all the bits and print the result as an unsigned integer.
Link: https://www.hackerrank.com/challenges/flipping-bits/problem
Thinking process:
(1) How to write binary form?
example: Divide number by 2**16, the result is the first bit. As we write that bit, minus n by 2**16 so that we keep reducing the number.
(2) as we write, we can flip the 1 and 0 and add them up.
Python 3 Solution:
Complexity:
time: 0(n)
memory: o(1)
Comments and suggestions welcome!