You are viewing a single comment's thread. Return to all comments →
T = int(input().strip()) for _ in range(T): n , k = map(int , input().split()) print(k-1 if ((k-1) | k) <= n else k-2)
Before reading the explanation below , try to find the pattern using a brute force solution.
Seems like cookies are disabled on this browser, please enable them to open this website
Day 29: Bitwise AND
You are viewing a single comment's thread. Return to all comments →
A solution in Python 3:
NOTE:
Before reading the explanation below , try to find the pattern using a brute force solution.