Skip to content

Bit Manipulation

Problem Complexity Key Pattern
Counting Bits O(n) DP on binary representation — "count set bits for 0..n", "Hamming
Reverse Bits O(1) (fixed 32 iterations) Bit-level transformation — "reverse bits", "swap nibbles/bytes",
Single Number O(n) XOR uniqueness — "find the element appearing once while others appear