Data Structures & AlgorithmsModerateGATE CS · TCS NQT

How many contiguous subarrays of [2, 5, 3, 4, 10] have a product divisible by 10?

  1. A. 10
  2. B. 7
  3. C. 9
  4. D. 12

Correct answer: C. 9

A product is divisible by 10 when it contains a factor 2 and a factor 5. Count subarrays that contain both, using the positions of 5s and even numbers.

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

Exams that ask this topic