Question bank › Bit Manipulation
Dsa Bit Manipulation Medium

Total Bit Differences

You are given two integers a and b. Your task is to determine the total number of differing bits between the binary representations of a and b. This is known as the Hamming distance. Input: Two integers a and b (0 <= a, b <= 10^9). Output: An integer representing the Hamming distance between the two integers. Example: Input: 1 4 Output: 2 Explanation: The binary representations are: 1 -> 0001 4 -> 0100 The differing bits are in positions 1 and 3.

Key concepts

bit manipulationhamming distancecounting bits

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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.