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!
Select
Add answer anonymously...
Wells Fargo Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits