Number Complement
Easy
Math
Bit Manipulation
Given a positive integer, flip all bits in its binary representation.
Constraints
1 ≤ num < 2^31
Examples
Example 1:
Input: 5
Output: 2
Explanation: 5=101→010=2
Example 2:
Input: 1
Output: 0
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console