Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 786 |

@arpitsatnalika | 777 |

@tujhekya | 602 |

@prakharxyz | 601 |

@code_it_ | 591 |

@iamronak | 505 |

@imnm | 500 |

@pradeepkumarjad | 488 |

@satyam0460 | 481 |

@nitesha125 | 468 |

@Rahul Jadhav 1 | 466 |

Complete Leaderboard |

Given two numbers **M** and **N**. The task is to find the position of the **rightmost different** bit in the binary representation of numbers.

**Example 1: **

**Input: **M = 11, N = 9
**Output:** 2
**Explanation:** Binary representation of the given
numbers are: 1011 and 1001,
2nd bit from right is different.

**Example 2:**

Input:M = 52, N = 4Output: 5Explanation: Binary representation of the given numbers are: 110100â€¬ and 0100, 5th-bit from right is different.

**User Task:**

The task is to complete the function **posOfRightMostDiffBit**() which takes** two arguments m and n** and **returns** the **position of first different bits in m and n**. If both m and n are the same then return **-1** in this case.

**Expected Time Complexity:** O(max(log m, log n)).

**Expected Auxiliary Space:** O(1).

**Constraints:**

1 <= M <= 10^{3}

1 <= N <= 10^{3}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Rightmost different bit

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.