Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

What is the maximum value of a[i] XOR a[j] over index pairs i < j in [3, 10, 5, 25, 2, 8]?

  1. A. 27
  2. B. 35
  3. C. 28
  4. D. 32

Correct answer: C. 28

A binary trie greedily picks the opposite bit at each level. The best pair is 5 and 25, with 5 XOR 25 = 28.

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

Exams that ask this topic