dsa · easy

Number Complement

Take the binary writing of the positive integer num **without** leading zeros, flip every bit (0 becomes 1, 1 becomes 0), and return the integer that binary represents.

Example

num = 10 is 1010. Flip each bit: 0101, which is 5.

num = 1 is 1. Flip: 00.

num = 7 is 111. Flip: 0000.

Do not flip an infinite prefix of leading zeros — only the bits that appear in the minimal binary writing of num.

## Arguments - num — positive integer whose bits (no leading zeros) you flip

Constraints

1 <= num <= 2^31 - 1

Examples

Example 1

Input:
10

Expected:
5

Example 2

Input:
1

Expected:
0

Example 3

Input:
7

Expected:
0

Open in the Dojo editor