Data Structures & AlgorithmsHard

How many contiguous subarrays of 2 5 1 5 3 4 contain the maximum VALUE of the subarray exactly once?

  1. A. 15
  2. B. 6
  3. C. 9
  4. D. 16

Correct answer: A. 15

For each subarray count how many times its maximum value appears; the answer keeps blocks where that count is one. Counting blocks with repeated maxima, testing distinctness, or dropping singletons gives other totals.

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

Exams that ask this topic