Dsa
Bit Manipulation
Warm-up
Sum of Bit Differences
Given two integers A and B, return the sum of the differences of their bits at each position.
Input format:
- Two integers A and B (-2^31 <= A, B <= 2^31 - 1)
Output format:
- A single integer representing the sum of the bit differences.
Example:
Input:
10 20
Output:
4
(Note: 10 is '1010' and 20 is '10100'. Bit differences occur at positions 1, 2, and 4.)
Key concepts
bit manipulationdifference calculation
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