Tap here to switch tabs
Problem
Submissions

Problem: Number Complement

med
30 min
Try to solve the Number Complement problem.

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

med
30 min
Try to solve the Number Complement problem.

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}