Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div 2

What is the maximum value of A[i] ⊕ A[j] over pairs i < j in A = [3, 10, 5, 25, 2, 8]?

  1. A. 25
  2. B. 27
  3. C. 28
  4. D. 26

Correct answer: C. 28

The maximum comes from 5 ⊕ 25 = 28 (00101 ⊕ 11001 = 11100). The largest element, 25, is only the trap, because XOR is not monotone in its operands.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic