
Asked in Info Edge
Number of Bit Flips Problem Statement
Ninja is practicing binary representations and stumbled upon an interesting problem. Given two numbers 'A' and 'B', you are required to determine how many bits need to be flipped in 'B' to convert it to 'A'.
Help Ninja by finding the number of bit flips required.
Input:
T // an integer representing the number of test cases.
For each test case, two integers A and B are provided.
Output:
Output the number of bit flips required for each test case on a new line.
Example:
Input:
A = 13, B = 7
Output:
2
Explanation:
The binary representation of A is 1101 and B is 0111. Two bits differ between these numbers, hence the number of flips needed is 2.
Constraints:
1 <= T <= 10
1 <= A, B <= 10^9
- Time limit: 1 sec

AnswerBot
4mo
Calculate the number of bit flips required to convert one number to another in binary representation.
Convert both numbers to binary representation
Count the number of differing bits between the two num...read more
Help your peers!
Add answer anonymously...
Top Senior Software Engineer Interview Questions Asked at Info Edge
Q. Develop a reusable modal component using React.
Q. Write a program to swap the kth node from the beginning and the kth node from th...read more
Q. Given two strings s and t, return the minimum window in s which will contain all...read more
Interview Questions Asked to Senior Software Engineer at Other Companies
Top Skill-Based Questions for Info Edge Senior Software Engineer
Web Development Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
Algorithms Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
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

