Blind 75 Bit Manipulation Questions
5 problems · Free practice
Bit manipulation uses the representation of integers directly. XOR can cancel equal values, masks can isolate a bit, and shifts move bits between positions. Fixed-width problems also require attention to the language: signed integers and unbounded integers do not automatically behave like unsigned 32-bit values.
Practice bit manipulation
Number of 1 Bits
EasyCount the set bits in an unsigned 32-bit integer.
Counting Bits
EasyFor every integer from 0 through n inclusive, return its number of set bits. Assume n ≥ 0.
Reverse Bits
EasyReverse the order of all 32 bits in an unsigned 32-bit integer and return the resulting unsigned value. Leading zeros participate.
Missing Number
EasyAn array of length n contains distinct integers chosen from 0 through n. Find the one value that is absent.
Sum of Two Integers
MediumCompute the sum of two signed 32-bit integers without using addition or subtraction operators. Use 32-bit two’s-complement wraparound if overflow occurs.
What to focus on
- Check the problem’s integer width and signedness before using shifts.
- Explain a bitwise identity with a tiny binary example.
- Test zero, the highest bit, and values containing several adjacent set bits.