XOR Value Pair

BIT MANIPULATION

Problem

Given an array arr of integers, find the pair of elements that yields the minimum XOR value and return that value.

Assume that the array has at least two elements.

Examples

minXORValue([4, 3, 8, 9]) // returns 1 /* The pair (8,9) gives the minimum XOR value. 8 in binary is 1000 and 9 in binary is 1001. The XOR of 8 and 9 gives 0001 which is 1 in decimal. */
Loading...