Topics / Bit Manipulation
💡
Bit Manipulation
AND, OR, XOR, shifts, and the little tricks (n & -n, n & (n-1)) that win interviews.
Why learn Bit Manipulation?
-
Tiny topic, big interview signal.
-
Unlocks elegant O(1) solutions to specific problems.
-
A required tool for low-level and systems work.
What you can build with Bit Manipulation
Single-number (XOR) family Bitmask DP Low-level system flags and permissions
Bit Manipulation tutorials
2 articlesHand-written tutorials, ordered as a recommended learning path.
- 01 Bit Manipulation A practical introduction to bit manipulation in Python — binary representation, the bitwise operators, two's complement, and the common operations to set, clear, toggle, and check individual bits.
- 02 Bit Tricks Six classic bit manipulation problems — Single Number, Number of 1 Bits, Power of Two, Counting Bits, Missing Number, Reverse Bits — plus the tricks that make them tick: n & (n-1), n & -n, and XOR cancellation.