Build bit manipulation skills through basic bit checks, XOR reasoning, number properties and coding interview applications.
Log in/Sign up to track your progress
Striver’s Bit Manipulation Sheet contains 16 coding questions. Three source exercises have been added to the retained 13-question selection: checking whether a number is odd, checking whether the i-th bit is set, and swapping two numbers. The list then develops bit operations, XOR reasoning and related number problems.
Striver’s Bit Manipulation Sheet contains 13 problems covering bit properties, counting, XOR cancellation, subset masks and arithmetic. The questions also connect bit operations with hashing through prefix XOR. This gives you practice recognising when a short binary rule is enough and when you still need to store information about earlier values.
Use the sheet to understand the conditions behind each technique. A rule that works when every repeated value appears twice may fail when repetitions occur three times. Similarly, a shift that is valid for a chosen unsigned width needs extra care with negative values or a different language representation.
The foundation questions make individual bits and simple bit operations concrete before they are combined in larger expressions. Later questions use bit properties to reason about values, counts or repeated numbers. The exact representation and input rules matter, especially for signed values and shifts.
Use Introduction to Bits and Tricks to understand binary representation, AND, OR, XOR, NOT and shifts. Know integer arithmetic, conditions and loops first. Check the chosen language’s rules for signed integers and shift operations instead of assuming every representation behaves identically.
Know binary place values and the meanings of AND, OR, XOR, NOT and shifts. Practise reading one small nonnegative number in binary before applying a formula. Keep a bit position separate from a mask: position three identifies a location, while a mask with that bit set is a numeric value.
Choose the representation your reasoning assumes. Fixed-width integer types have a limited number of positions; Python integers can grow as needed. Signed shifts and complements require language-specific care. A complement intended to affect only a chosen number of low bits needs an explicit width mask rather than an assumption that every language discards higher bits.