Number Complement
Write num in binary without leading zeros, flip every bit (0 becomes 1, 1 becomes 0), and return the number the flipped bits represent.
Example 1
num 5
returns 2
101 flips to 010, which is 2.
Example 2
num 1
returns 0
1 flips to 0.
Constraints
1 <= num <= 2**31 - 1
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.