Problem Brief
Max XOR
OA
For two positive integers, lo and hi, and a limit k,
find two integers, a and b, satisfying the following criteria.
Return the value of a e b. The • symbol denotes the bitwise XOR operator.
lo <= a < b <= hi- The value of
a e bis maximal fora e b ≤ k.
Function Description
Complete the function maxXor in the editor below. The function must return an
integer denoting the maximum possible value of a e b for all a e b ≤ k.
maxXor has the following parameters:
int lo: an integerint hi: an integerint k: an integer
1Example 1
Input
lo = 3, hi = 5, k = 6
Output
6
Explanation
The maximal useable XORed value is 6 because it is the maximal value that is less than or equal to the limit k = 6.
Constraints
Limits and guarantees your solution can rely on.
1 ≤ lo < hi ≤ 10^41 ≤ k ≤ 10^4