Dsa
Bit Manipulation
Easy
Count Different Bits
Write a program that takes two integers and counts the number of bits that are different in their binary representations.
Input format:
- A single line containing two integers A and B (0 <= A, B <= 10^9).
Output format:
- An integer representing the number of differing bits.
Example:
Input:
3 5
Output:
1
(Binary of 3 is '11' and binary of 5 is '101', differing at one position.)
Key concepts
bit_manipulationcomparison
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