Longest common substring value of two numbers
Submissions: 1809   Accuracy:

18.79%

  Difficulty: Medium   Marks: 4

Given two integers N and M. The task is to find the longest contiguous subset in binary representation of both the numbers and print its decimal value.

Note: If there are two or more longest common substrings with the same length, the print the maximum value of all the common substrings.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow.
Each test case contains two integer N and M as input.

Output:
For each test case, print the decimal value of longest common substring In new line.

Constraints:
1<=T<=1000
1<=N,M<=1018

Example:
Input:
2
10 11
8 16

Output:
5
8

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arun Tyagi
Author: arun03


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.