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?