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.
Strip your number down to the most significant bit followed by some amount of 0s or 1s thereafter. This can be done using l^r. The first time one of the numbers has a 1 and the other doesn't, this will be your most significant bit.
Set all the following 0s to 1s. If 1000 is your most significant, the maximum will be 1111.
Print the decimal interpretation of the resulting binary number.
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 →
Consider this: https://www.hackerrank.com/challenges/maximizing-xor/submissions/code/44305239