Bit Manipulation
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.
Bit Manipulation
Visualize bitwise operations at the binary level. Each result bit is computed independently from the bit pair directly above it — essential for low-level optimization, masks, and flags.
Combining column 4: 0 & 0 = 0
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 hereTest your knowledge
Which property of XOR allows finding a unique number in pairs?
Write the code
Single Number
The short version
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.
In more depth
Bitwise Power
Bit manipulation involves working directly with the binary representations of data.
Essential Tricks:
x ^ x = 0x ^ 0 = xx & 1 checks if x is odd/even.x & (x-1) clears the lowest set bit (helps count set bits).When to reach for this
- Low-level optimization
- Representing sets using bitmaps
- Finding unique numbers
- Counting set bits (Hamming Weight)
Interview Questions
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required