Dsa
Bit Manipulation
Medium
Count Unique Bits
You are given a positive integer n. Your task is to find how many unique bits (1s) are present in its binary representation.
For example:
Input:
12
Output:
2
Explanation:
The binary representation of 12 is 1100, which has two unique bits (1s).
Key concepts
bit manipulationcountingbinary
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now