We’re preparing your current view and syncing the latest data.
Given a positive integer n, output its complement number. The complement strategy is to flip the bits of its binary representation (changing 1s to 0s and 0s to 1s) to form a new binary number and return its base-10 integer representation.
A single integer n, where n is the integer to find the complement of.
An integer representing the complement of the input integer n.
1 <= n < 10^9
Example 1
Input
5
Output
2
Explanation
Binary of 5 is 101, flipping bits gives 010 which is 2 in decimal.