Let's say we have given set of integers $A = \{x_1, x_2, x_3, x_4, \dots, x_n\}$, consisting of exactly $n$ values, all of them positive integers. Now the problem is to find the maximum value of bitwise or operation of all possible pairs $(x_i, x_j)$
We define bitwise or as bitwise operation that returns true if atleast one of the bits is turned on, in most programming languages it is declared as "|".
Edit: We assume that the numbers in the set can be written with at most 17 bits, or they are smaller than $2^{17}$.
For example, we have: $n=4, A = \{12, 3, 4, 11\}$ the maximum value of bitwise or will be $15$, because $12|3=15, 11|4=15, 12|11=15$ so the result is $15$ and we have exactly $3$ pairs that give this result.
My thinking
Obviously we can take each pair and see what is their bitwise or, but this leads us to solution in $O(N^2)$, and I think that there is much faster solution, I think that we don't need to calculate the bitwise or of all numbers, and we can only calculate it for some numbers.