Tap here to switch tabs
Problem
Submissions

Problem: Number Complement

Number Complement gives you a positive integer and asks you to return the value formed by flipping every bit in its binary representation without leading zeros.

Statement

The complement of an integer is the number obtained by inverting all the bits in its binary representation without leading zeros, converting each 00 to 11 and each 11 to 00.

Given an integer num, return its complement.

Constraints:

  • 1≤1 \leq num <231< 2^{31}

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number Complement

Number Complement gives you a positive integer and asks you to return the value formed by flipping every bit in its binary representation without leading zeros.

Statement

The complement of an integer is the number obtained by inverting all the bits in its binary representation without leading zeros, converting each 00 to 11 and each 11 to 00.

Given an integer num, return its complement.

Constraints:

  • 1≤1 \leq num <231< 2^{31}