Bit Manipulation
8 min read.
Bit manipulation involves working directly with the binary representation of data. Master AND, OR, and XOR operations—three fundamental bitwise operations used in competitive programming, systems optimization, and low-level algorithms. Learn to solve problems like finding unique elements in linear time, testing powers of two, and implementing efficient bitmasks for sets. Essential knowledge for interview questions and real-world performance-critical code.
Think of it this way: Think of light switches. Each bit is just a switch (ON/OFF). Bit manipulation allows you to flip specific switches or check patterns incredibly fast, far faster than doing math.
12 & 10: combine the bits column by column, from the right.
Check your understanding
Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.
Which operator?
Sort each trick by the bitwise operator that replaces the ?.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
AND (&)
Drop items hereOR (|)
Drop items hereXOR (^)
Drop items hereQuiz
20 questionsWhich property of XOR allows finding a unique number in pairs?
Done with this lesson?
Sign in free to keep your progress, streak and quiz scores.