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.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.