Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

What is the minimum value of a[i] XOR a[j] over index pairs i < j in [15, 2, 19, 6, 11, 9]?

  1. A. 2
  2. B. 3
  3. C. 1
  4. D. 17

Correct answer: A. 2

After sorting, the minimum XOR is achieved by two adjacent values, because the highest differing bit is minimised by neighbours. Checking neighbours alone is enough.

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

Exams that ask this topic