Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many unordered index pairs i < j in [2, 3, 4, 5, 6] have a[i] + a[j] prime?

  1. A. 5
  2. B. 6
  3. C. 8
  4. D. 4

Correct answer: D. 4

Sums are 5, 6, 7, 8, 7, 8, 9, 9, 10, 11; the primes among them are 5, 7, 7, 11, so count those pairs.

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

Exams that ask this topic