ProgrammingHardTCS NQT · Infosys

How many index pairs i < j in the array {3, 5, 3, 5, 7} satisfy a[i] XOR a[j] == 0?

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

Correct answer: B. 2

a[i] XOR a[j] is 0 exactly when the values are equal. The value 3 appears twice and 5 appears twice, giving two pairs.

More C Programming questions

Exams that ask this topic