An (sorted) array consists of (a random amount of) random unique integers between 0 and 2^32 - 1.
In base 2 the array could, for example, look like this:
Given another random integer x between 0 and 2^32 - 1, how do I find the integer in the array that shares the most ones and zeros with x in the same position (in binary notation)? If there are multiple cases, any of the cases will do.
The following two numbers will, for example, differ in only one place:
I cannot check them one at a time, I need to do it faster. A binary search-style approach would be perfect.
Feel free to transform the array and x into something else.