Bit Manipulation Interview Questions: Complete Guide (2026)
What bit manipulation interview questions actually test, which categories appear most often at top companies, and how real data from LeakCode changes your prep strategy.
What bit manipulation interviews evaluate
Bit manipulation problems test fluency at the hardware-integer layer of computing. They reveal whether a candidate understands two's complement representation, sign extension, and the efficiency characteristics of bitwise operations. In practice this matters for low-latency systems, database internals, and graphics or game engine code.
In LeakCode's dataset of 51,000+ interview reports, bit manipulation questions cluster at two extremes: short clever one-liners that test whether you know the XOR identity or the n & (n-1) trick, and longer bitmask dynamic programming problems that require composing bit operations with a full DP recurrence. Both categories appear in FAANG interviews.
Interviewers specifically watch whether candidates can translate verbal reasoning (I need to check if bit k is set) into the correct expression (n >> k & 1) quickly and confidently, without fumbling operator precedence.
Main categories of bit manipulation problems
Bit counting and population
Counting set bits in an integer or in a range of integers. Includes Hamming distance, total set bits from 1 to n, and efficient bit-count across arrays. The n & (n-1) trick that clears the lowest set bit in O(1) is the core primitive. Appears at Google, Amazon, and Microsoft.
XOR-based uniqueness and pairing
The XOR identity (a XOR a = 0) enables finding a single non-paired element in an array, finding two non-paired elements, or detecting bit-level differences between two values without a comparator. These problems have O(n) time and O(1) space solutions that look deceptively simple. Heavily reported in Meta and Amazon phone screens.
Power of two and divisibility tricks
Detecting whether n is a power of two (n & (n-1) == 0 and n > 0), checking divisibility by powers of two using bit masks, and computing the next power of two. These appear as warmup questions and as sub-problems inside larger questions about memory alignment or bucket sizing.
Bitmask dynamic programming over subsets
DP problems where the state space is the set of all subsets of n items, represented as integers from 0 to 2^n - 1. Used for problems like shortest Hamiltonian path, minimum cost to cover all tasks, and assignment problems. These appear in hard-level Google and Meta onsite rounds and require combining subset enumeration with standard DP transitions.
Bit manipulation in number representation problems
Problems involving reversing bits in a 32-bit integer, adding without the plus operator, multiplying using only shifts and additions, or converting between signed and unsigned representations. These test low-level reasoning and appear more in systems-focused teams and companies like Apple and Qualcomm.
How to approach bit manipulation in an interview
The most common mistake candidates make is jumping to code before establishing which bit property is being exploited. Before writing a line, name the relevant identity or operation: "This is an XOR pairing problem," or "I need to enumerate subsets using the standard for s = mask; s > 0; s = (s-1) & mask pattern."
- 1.State the key property. Identify whether you need XOR cancellation, lowest-set-bit extraction, subset enumeration, or a shift-based arithmetic trick before touching the keyboard.
- 2.Write out operator precedence explicitly. Bit operations have lower precedence than comparison operators in most languages. Parentheses prevent bugs and demonstrate carefulness.
- 3.Test with small examples by hand. Run through 3-4 bit trace using binary representations. This catches off-by-one shifts and sign-bit issues before the interviewer points them out.
- 4.Discuss integer width assumptions. Clarify whether the problem assumes 32-bit or 64-bit integers, signed or unsigned. This is especially relevant for shift and NOT operations.
Companies that ask bit manipulation questions
Browse real bit manipulation interview reports from these companies on LeakCode:
Search Bit Manipulation on LeakCode
LeakCode has 51,000+ real interview questions from 2,000+ companies. See which bit manipulation patterns your target company actually asks, not what textbooks assume.
Browse Bit Manipulation QuestionsHow LeakCode helps with bit manipulation prep
LeakCode aggregates real candidate reports from 1Point3Acres, Blind, LeetCode Discuss, Glassdoor, and Reddit. You can filter by company and round type to distinguish which bit manipulation categories appear in phone screens versus onsite loops. This prevents over-preparing niche topics that your target company never asks.
See also: how LeakCode works, our data sources, and FAQ. Related guides: dynamic programming interview questions, graph interview questions, and backtracking interview questions.
XOR: the workhorse of bit-manipulation interviews
XOR has two properties that make it the dominant operator in bit-manipulation interview problems: a XOR a = 0 (self-cancellation) and a XOR 0 = a (identity). Combined, these let you find an element appearing once in an array where every other element appears twice: XOR all elements together; pairs cancel out, the unique survivor remains. This is a classic L4 problem at Google, Meta, and Amazon.
XOR variants that appear at senior+ levels: find the unique element when every other appears three times (use bit-counting modulo 3 for each bit position). Find two unique elements when others appear twice (XOR all, find any set bit in the XOR result, split the array by that bit, XOR each half separately). Missing number from 0 to n: XOR all elements with XOR of 0 to n. These appear repeatedly in interview reports tagged "bit manipulation" on LeakCode.
Bitmask DP appears more than expected
Bitmask dynamic programming encodes a subset of n elements (n less than or equal to 20 or so) as an integer bitmask. State transitions add or remove elements via bitwise operations. Classic applications: Travelling Salesman with current position + visited set, assignment problems where each job goes to one person, partition into k subsets with a property.
Common one-liners worth memorizing: iterate over all subsets of a mask via sub = mask; while sub > 0: ...; sub = (sub - 1) & mask. Check if bit i is set: mask & (1 << i). Toggle bit i: mask ^ (1 << i). Clear the lowest set bit: mask & (mask - 1). Reports on LeakCode show candidates who produce these one-liners without hesitation score materially higher on bitmask-DP problems.