Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

In [6, 3, 6, 9, 3, 9, 9, 5, 5] exactly one value appears an odd number of times and every other value appears an even number of times. What is that value?

  1. A. 10
  2. B. 11
  3. C. 3
  4. D. 9

Correct answer: D. 9

XOR cancels pairs, so the total XOR equals the value appearing an odd number of times. Here 9 appears three times and is the odd one out.

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

Exams that ask this topic