We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Ah, so let me start with an example. Lets say L is 92 and R is 95.
L = 1011100
R = 1011111
L xor R would be 0000011. We can create every possible combination WITHIN that 11 because that is the difference between them.
Think of it like a decimal number, if we had numbers of 9480 and 9489 and we were looking for the digits between them we know they all start with '948,' so the only variance is that last digit, which can be 1-9. Take another case, 976590 and 978590. Even though they match a lot, 97_590, that '590' match doesn't matter, only the first difference. we know that the following digits can vary between '6590' all the way through '8590,' giving us a range of 2000 digits.
Similarly, we know that these two binary numbers start with the same digits, and within the range we have we can alter everything after the first mismatch in digits.
Hope that helps!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximizing XOR
You are viewing a single comment's thread. Return to all comments →
Ah, so let me start with an example. Lets say L is 92 and R is 95.
L = 1011100
R = 1011111
L xor R would be 0000011. We can create every possible combination WITHIN that 11 because that is the difference between them.
Think of it like a decimal number, if we had numbers of 9480 and 9489 and we were looking for the digits between them we know they all start with '948,' so the only variance is that last digit, which can be 1-9. Take another case, 976590 and 978590. Even though they match a lot, 97_590, that '590' match doesn't matter, only the first difference. we know that the following digits can vary between '6590' all the way through '8590,' giving us a range of 2000 digits.
Similarly, we know that these two binary numbers start with the same digits, and within the range we have we can alter everything after the first mismatch in digits.
Hope that helps!