8

PROBLEM OF THE DAY : 19/12/2023 | Rightmost different bit

 6 months ago
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-19122023-rightmost-different-bit/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

PROBLEM OF THE DAY : 19/12/2023

December 20, 2023 |510 Views
PROBLEM OF THE DAY : 19/12/2023 | Rightmost different bit
Problem of the Day, Data Structures and Algorithms, bit-magic
 Save  Share  1 Like
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

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK