Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

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

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

Correct answer: C. 1

Every subarray product that is 12 is found by extending from each start while the product stays at most 12, since all values are positive. Ones in the array extend subarrays without changing the product.

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

Exams that ask this topic