Given two integers m and n where m < n find the maximum pair-wise xor sum. The question is how to choose m distinct integers from 1 to n such that using those m numbers yields the maximum pair-wise xor sum.
The maximum pair-wise xor sum is calculated on a set of integers x as F(x) = sum( number_of_bits( xor(x[i], x[j]) ) for i = 1 to k, j = (i + 1) to k )
For example: if x = [4, 6, 8], let CB(num) return number of 1 bits in the number. F(x) = CB(4 xor 6) + CB(4 xor 8) + CB(6 xor 8) = CB(2) + CB(12) + CB(14) = 1 + 2 + 3 = 6
The brute force solution could be to generate all subsets of size m and then computing the pair-wise xor sum for each and then taking the maximum out of those. That would be exponential in terms of time.