Data Structures & AlgorithmsModerate

How many pairs of positions i < j in 2 3 4 6 8 9 12 satisfy that A[j] is divisible by A[i]?

  1. A. 0
  2. B. 17
  3. C. 10
  4. D. 11

Correct answer: C. 10

Divisibility is checked for the later element against the earlier one, so the pair order matters. Reversing the test, counting the diagonal, or counting equal values answers a different question.

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

Exams that ask this topic