Data Structures & AlgorithmsModerateGATE CS · TCS NQT

How many elements of the array [6, 12, 18, 24, 30] are divisible by at least one element that appears before them in the array?

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

Correct answer: A. 4

Check each element against all earlier ones; the first element has no predecessor and does not count. Dividing by the element itself is excluded.

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

Exams that ask this topic