Approach for the question

Can you please share the approach for this question

https://online.codingblocks.com/app/player/158042/content/150546/4977/code-challenge

Hey , tell me the name of the problem you are having trouble in. As i don’t have access to your course.

XOR profit problem of Bitmasking section

Okay i got it, see this discussion and you will get the intuition of how it’s working.
Xor problem

Examples 2:
L = 16 R = 20
L ^ R = (10000) ^ (10100) = (00100)
Now as L ^ R is of form (1xx) we can
get maximum xor as (111) by choosing
A and B as 19 and 20 (10011 and 10100)

Can you pls explain this example in detail and how are we so sure that we wont get a number which has a set bit at thousand’s place in this example?

See you are mixing things let me clear this
take any 2 number of your wish, just a wild guess i am taking L= 8 & R=20
Now binary of 8 is 01000
And binary of 20 is 10100
do xor of 8^20 what do we get is 11100, now what is it of form 1xxxx
Now we will run 2 pointer one from 8 and another from 20 to check if we can get xor more than 1xxx or not and when we will do it we will find 2 values which can get maximum XOR as (11111) by choosing A and B as 15 and 16 (01111
and 10000)

Just dry run the code with different inputs and you will get the intuition for sure. The code is attached in this link you can see and try it.