Data Structures & AlgorithmsVery hardAmazon OA · Arrays

How many contiguous subarrays of [2, 3, 4, 1, 5, 2, 6] have a product strictly less than 50?

  1. A. 17
  2. B. 19
  3. C. 18
  4. D. 20

Correct answer: B. 19

A sliding window with the product kept below 50 adds (window length) new subarrays per right end; the window lengths are 1, 2, 3, 4, 3, 4, 2, which sum to 19.

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

Exams that ask this topic