Dsa
Bit Manipulation
Medium
Count Duplicated Bits
You have a number which has some bits that are set (1) and some that are not (0). Write a program to count how many bits in the number are duplicated (set bits that appear more than once in the binary representation). Print the count of duplicated bits.
Example:
Input:
15
Output:
4
Key concepts
bit_manipulationcounting
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