Data Structures & AlgorithmsVery hardProduct placement · Amazon/Microsoft

How many contiguous subarrays of [6, 4, 2, 5, 6, 2, 3, 3] have a product strictly less than 30? (Positive values: a two-pointer window adds right − left + 1 subarrays at each right end.)

  1. A. 16
  2. B. 36
  3. C. 15
  4. D. 14

Correct answer: C. 15

Grow the window to the right and shrink while the product is ≥ 30; each step adds the number of subarrays ending at the right edge. The total is 15.

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

Exams that ask this topic