EASYasked at 6 companies

Number of 1 Bits

A easy-tier problem at 75% community acceptance, tagged with Divide and Conquer, Bit Manipulation. Reported in interviews at AMD and 5 others.

Founder's read

Number of 1 Bits is an easy problem that appears deceptively simple: count the set bits in an integer. AMD, Qualcomm, Nvidia, and Cisco have all asked it. The 74% acceptance rate is high, but that's the trap. Most candidates brute-force it, miss the clever bit manipulation tricks, and then panic when an interviewer asks them to optimize further. You need to know the standard approaches cold, because this is often a warm-up question that sets the tone for harder problems. If you blank on the bit-shifting trick during a live assessment, StealthCoder surfaces the solution invisibly while you stay calm.

Companies asking
6
Difficulty
EASY
Acceptance
75%

Companies that ask "Number of 1 Bits"

If this hits your live OA

Number of 1 Bits is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.

Get StealthCoder
What this means

The problem wants you to count how many 1s appear in the binary representation of a number. The naive approach iterates through every bit, checking if it's set. That works and gets you past acceptance, but interviewers drill into optimizations. The clever trick is Brian Kernighan's algorithm: n & (n-1) removes the rightmost set bit in one operation, so you loop only as many times as there are 1s. This uses Bit Manipulation and a divide-and-conquer mindset. The pattern is easy to forget under pressure, especially if you haven't coded it recently. StealthCoder is your insurance policy: if you freeze during the live OA, you get a working solution in seconds, invisible to the proctor, so you move on without derailing the interview.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Number of 1 Bits recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Number of 1 Bits interview FAQ

Is this problem really asked at big tech companies?+

Yes. AMD, Qualcomm, and Nvidia have confirmed asks. It's typically used as a warm-up or a second-round filter. The 74% acceptance rate might suggest it's trivial, but that masks the gap between 'passes test cases' and 'articulates the optimal bit trick clearly.'

What's the trick everyone expects you to know?+

Brian Kernighan's algorithm: n & (n-1) strips the rightmost 1 bit. Loop until n is zero. This solves it in O(k) where k is the number of 1 bits, instead of O(log n) for brute force. It's elegant once you see it, brutal if you don't.

How does this relate to Divide and Conquer?+

Divide and Conquer shows up because you can solve it recursively: split the number in half, count 1s in each half, combine results. It's less efficient than the bit trick, but interviewers sometimes ask you to code both approaches to show you understand the pattern family.

Should I memorize the solution or understand it?+

Understand it first. The bit operation n & (n-1) is the core insight. Once you see why it works, you can code it from first principles in any language. Memorizing without understanding trips you up under pressure.

What's the biggest mistake candidates make?+

Overthinking language-specific tricks instead of focusing on the algorithm. Some languages have built-in bit-count functions; interviewers expect you to implement it yourself anyway. Stick to the bit manipulation approach and you're safe.

Want the actual problem statement? View "Number of 1 Bits" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.