Data Structures & AlgorithmsModerateCodeforces Div 2 C · ICPC regional

Choose a from {6, 9, 12} and b from {3, 5, 10}. What is the largest possible value of a XOR b?

  1. A. 12
  2. B. 17
  3. C. 15
  4. D. 8

Correct answer: C. 15

Enumerate the nine pairs, or use the highest differing bit greedily. The XOR of 12 and 3 is 15, the largest of the nine values, while AND-based or sum-based choices are different quantities.

More Coding Interview Problems questions

Exams that ask this topic