Number of Mismatching Bits
Determine the number of bits that differ between the binary representations of two given integers "first" and "second".
Input:
The input starts with an integer ‘T’ representing the number of test cases.
Each of the following ‘T’ lines contains two space-separated integers, "first" and "second".
Output:
For each test case, output a single integer on a new line representing the number of mismatched bits in the binary representation of the two integers.
Example:
Input:
3
11 15
23 56
10 20
Output:
1
4
4
Constraints:
- 1 <= T <= 105
- 0 <= first, second <= 109
Note:
Remember not to print anything; just implement the function to return the number of mismatching bits for the given pairs of numbers.

AnswerBot
4mo
Calculate the number of mismatching bits between two given integers in their binary representation.
Convert the integers to binary representation using bitwise operations.
Count the number of differing ...read more
Help your peers!
Add answer anonymously...
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

