Data Structures & AlgorithmsHardCodeforces Div2 D · ICPC regional

What is the maximum value of x XOR y over all pairs of DIFFERENT positions of the list [7, 12, 5, 9, 14, 3]?

  1. A. 15
  2. B. 2
  3. C. 13
  4. D. 14

Correct answer: A. 15

Build a binary trie of the values from the most significant bit and greedily choose the opposite bit at each level, which finds the best partner in O(n · bits). Brute force over pairs gives the same answer for small inputs.

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

Exams that ask this topic