Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 476. Number Complement
Given a positive integer, return the integer formed by flipping every bit in its binary representation up to its most significant 1 (i.e., invert all bits excluding leading zeros). This is a bit-manipulation problem—build a mask of 1s covering num's bit-length and xor/negate num against that mask (1 <= num < 2^31).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.