XOR of 2 numbers in given range which is smaller than or equal to K

Viewed 513

Given two numbers left and right and another number k, find maximum a XOR b less than or equal to k such that left <= a < b <= right.

One solution is to check all the pairs, but I feel there must be a constant time solution.

I know how to find a pair with maximum XOR value in constant time, is it somehow related to this problem?

0 Answers
Related