Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many ordered pairs of distinct positions (i, j) in [2, 3, 4, 6, 12] satisfy a[j] divisible by a[i]?

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

Correct answer: B. 7

Check divisibility for every ordered pair of distinct indices; each divisor-multiple relation counts once in the ordered direction. Halving the count treats the relation as symmetric, which it is not.

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

Exams that ask this topic