Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div2 B

How many contiguous subarrays of [1, 2, 3, 4, 6, 2] have a product exactly equal to 12?

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

Correct answer: C. 2

Enumerate all subarrays and check each product; the answer counts every window whose product is exactly 12, including the windows that contain the value 1 only when the product still matches.

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

Exams that ask this topic