Data Structures & AlgorithmsModerateGATE CS · competitive programming

How many unordered pairs {i, j} with i ≠ j in [1, 3, 5, 7, 2, 4] satisfy A[i] ⊕ A[j] = 6?

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

Correct answer: D. 3

The pairs are {1,7}, {3,5} and {2,4}, each with XOR 6. Checking all 15 pairs shows no others qualify.

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

Exams that ask this topic