PATTERN 16 · 5 PROBLEMS
Bit manipulation
Use bit identities to store many binary facts in one integer.
Start the first lesson ↗MASTER KEYWrite the bit truth table before the code.
0OF 5
RECALLED
RECALLED
n & (n−1) removes the lowest set bit.
Not started
↗02Number of 1 Bits
n & (n−1) removes the lowest set bit.
Not started
↗03Counting Bits
Removing the lowest set bit reaches a smaller number already solved.
Not started
↗04Reverse Bits
Every step transfers the current low bit into the next result position.
Not started
↗05Missing Number
Equal values cancel under XOR, leaving only the missing value.
Not started
↗Sum of Two Integers
XOR adds without carry; AND shifted left computes the carry.