Hi, I went through this solution, but the explanation is not clear to me. Please help.
Explanation not clear to me
Hi @sarthakbuddy
since a != b
then in the bitwise representation of a and b, there must be at least one bit such that a[i] != b[i] where a[i] is the ith bit of the number a.
We cannot change any bit before the first set bit of either number as the constraints might be violated.
Now if we find the first bit that is differing in both the numbers, for each bit afterwards, max XOR can be achieved by flipping a bit if it is same for both numbers. We can count the number of “1” in the resultant XOR operation and that will give us the 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.