whats the purpose of taking l^r initally i read many soln even the hints here but didnt get the l^r logic please explain
Doubt regarding why we have taken (l^r) for optimized apprach
Hi @chemant077
As the minimum and maximum numbers are l and r, hence we can have the msb of both as 1 or msb of l as 0 and msb of r as 1. So for xoring purpose, we need max of a^b meaning the msb of the answer should be 1 that is why we try to calculate first bit position that gives 1 in the answer. And all right positions to that set bit in a^b can be assumed to be 1.
Hope it Helps.
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.