Bit Manipulation Interview Questions & Solutions

11 solutions ยท 6 Easy ยท 5 Medium

Bit manipulation problems operate directly on the binary representation of numbers, and they have a reputation for looking like magic โ€” until you learn the handful of operations behind every trick. AND, OR, XOR, NOT, and shifts are the entire toolkit, and a surprising number of interview questions fall to a single clever application of XOR or a well-chosen bit mask.

These solutions demystify the standard set: using XOR's "cancel the pairs" property to find the single non-duplicated number, counting set bits, checking and toggling individual bits with masks, and the `n & (n-1)` trick that clears the lowest set bit. You'll see power-of-two checks, bitwise addition without the `+` operator, and subset enumeration via bit masks โ€” a technique that connects bit manipulation back to backtracking. For each one we explain why the bit trick works rather than asking you to memorize it, so you can derive it under pressure instead of hoping you remember. These problems are less common than DP or graphs, but when one appears, knowing the pattern is the whole difference.

Practice Bit Manipulation the right way

SkillFlow serves you Bit Manipulation problems matched to your level, times you like a real interview, and tracks your proficiency as it climbs. Free.

Start practicing free โ†’

Other interview patterns