let L and R are not equal means we will find at least one 0(zero) in LSB(least significant bit) of numbers from L to R and if there second last bits are 1 and difference between them is >1 means we will find at least one zero from L to R for second bit.
let L=2 and R=3 so there second bit is 1 and difference is not greater than 1 so in & operation we will not have zero at this position which is our objective. if we have 0 in any one of L or R then no need to do anything for that position.
if third bit is 1 (both L and R) then difference must be >3 to achieve zero at that position.
so the formula comes out for i(th) bit difference must be greater than or equal to 2^(i-1).
in this problem efficient algo is used But concept is same
so lets iterate with L = 110010110 and R = 110011101
in first iteration L and R are not equal means there is at least one zero in LSB of L to R. and multiply step by two so step = 10 means last bit is off (zero) and now right shift both(L,R) to remove LSB because we have done with LSB.
in second iteration (same as above) we have at least one zero from L to R so multiply step by two step = 100 second bit is also off. and right shift both
in third iteration L is not equal to R but there LSB is same means at least one of there bit except LSB is differ ( so if any one of more significant bit differ means LSB will definitely flip at least once ) so our third bit is also zero hence multiply step = 1000.
same for fourth bit and after fourth bit we have L==R means non of bit differ from each other so multiply ( L or R ) with step to get answer or left shift L << 4 to get answer.
it was explanation of your query but for more efficiency iterate form MSB to LSB and if bits are same then oK but when first time bits differ then make 0(zero) all of bits from that position to LSB because if more signi. bit will differ then less signi. bit will definitely differ.