Efficient solution not understood

I dont understand how the efficient solution works

hey @tusharnitharwal,
you can simply observe it as when you go from a low number to high number bit changes from right to left and leftmost bits are only affected when your number is getting bigger since then you require high powers of 2.so here we are going from L to R when we xored L and R and find the leftmost bit(1st set bit while going left to right).the bits which are left of this bits are 0(since we have find the leftmost set bit) this means this left bits never changes in the whole range from L to R.means only bits which are on the right side of this leftmost set bit changes we know XOR becomes 1 only when the bits are different since right bits from its left most bits are changing so there must exist a pair by xoring which we can make all bits from this leftmost set bit the rightest position all set.and that will be you answer(means just find leftmost set bit by xoring L and R and make all bits including this which are in the right side of this set and it will become your answer).
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.

I still cant understand the efficient solution

now you have to take an example and observe how the bits changes and why this answer is correct thwn you will get it.