bhaiya is que kaa jo editorial hai wo smjh aa rha hai………… pr aisa kyu kiya hai??
Xor profit problem question
mainly editorial wants to say that
To maximize A xor B, we want A and B to differ as much as possible at every bit index.
We first find the most significant bit that we can force to differ by looking at L and R.
For all of the lesser significant bits in A and B, we can always ensure that they differ and still have L <= A <= B <= R.
Our final answer will be the number represented by all 1s starting from the most significant bit that differs between A and B
E.G.
L = 10111
R = 11100
most significant differing bit differ at 2 index
01111 <-- here’s our final answer
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.