• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
December 20, 2023 |1.1K Views
PROBLEM OF THE DAY : 19/12/2023 | Rightmost different bit
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Jay Dalsaniya. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Bit Magic but also build up problem-solving skills.

In this problem, given two numbers M and N. The task is to find the position of the rightmost different bit in the binary representation of numbers. If both M and N are the same then return -1 in this case.

Example :

Input: 
M = 11, N = 9
Output: 
2

Explanation: 
Binary representations of the given numbers are: 1011 and 1001, 2nd bit from the right is different.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/rightmost-different-bit-1587115621/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-java-compiler/4f20b827-5021-42b7-8657-d9d0dc7645b4