r/programmingchallenges • u/mindlessCoder • Sep 15 '18
Find maximum xor
I was asked this question in an interview. Given three numbers L, R, X. We have to find a number Y such that Y⊕X is maximum and Y lies between L and R (both inclusive). One way is to use brute force and check all numbers from L to R but can we do better than this?
8
Upvotes
View all comments
Show parent comment
1
u/Introscopia Sep 16 '18
yea, I figured it didn't cover all possible cases, but I figured if I hadn't gotten the job at that point I'd just give up...