Data Structures & AlgorithmsHard

How many contiguous subarrays of 5 1 6 2 7 3 8 contain EXACTLY two values that are at least 5?

  1. A. 13
  2. B. 4
  3. C. 8
  4. D. 9

Correct answer: C. 8

The count of large values inside each block must be exactly two, so the test is a count per block rather than a presence test. Using at-least, the strict bound, or exactly three each change the answer.

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

Exams that ask this topic