You are viewing a single comment's thread. Return to all comments →
Here's my log(n) solution in C, n being the upper bound - which is 10^3 in this instance.
log(n)
n
10^3
int maximizingXor (int l, int r) { int exp; for (exp = 1 << 9; exp > 0; exp >>= 1) if ((exp & l) ^ (exp & r)) break; return (exp << 1) - 1; }
Seems like cookies are disabled on this browser, please enable them to open this website
Maximizing XOR
You are viewing a single comment's thread. Return to all comments →
Here's my
log(n)
solution in C,n
being the upper bound - which is10^3
in this instance.