The second explanation of XOR profit hint is great. Can I get the implementation part of it
Can I get the implementation of appar's solution
hello @aryan
chec this->
int maxXORInRange( int L, int R)
{
// get xor of limits
int LXR = L ^ R;
// loop to get msb position of L^R
int msbPos = 0;
while (LXR)
{
msbPos++;
LXR >>= 1;
}
// construct result by adding 1,
// msbPos times
int maxXOR = 0;
int two = 1;
while (msbPos--)
{
maxXOR += two;
two <<= 1;
}
return maxXOR;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.