Complement the Significant Binary Digits
Updated
Problem statement
Given a positive integer n, write it in binary without leading zeros. Flip each digit: change every 0 to 1 and every 1 to 0. Return the integer represented by the flipped digits.
For this exercise, assume that only the significant binary digits are flipped. Do not add leading digits or use a fixed-width signed complement.
Function
integerComplement(n: int) → intExamples
Example 1
n = 5return = 2The binary form of 5 is 101. Flipping its three digits gives 010, which represents 2.
Example 2
n = 8return = 7The binary form 1000 becomes 0111, which represents 7.
Constraints
- For this exercise, assume
1 <= n <= 2147483647.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
- Address on Same PageNVIDIA · OANVIDIA interview questions
- Three-Speaker Truth ConsistencySusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Find the Missing Number from 1 to nGEP · OA
- Invert Ad Visibility BitsJP Morgan Chase · OAJP Morgan Chase interview questions
- Are They PangramsVanguard · OAVanguard interview questions
- Count Times Using at Most Two DigitsLSEG · OALSEG interview questions
- Minimum Tokens RemainingMicrosoft · OAMicrosoft interview questions
- Minimum Operations to Make Binary PalindromicGoogle · OAGoogle interview questions
- Powers of 2Oracle · OAOracle interview questions