Data Structures & AlgorithmsHard

How many contiguous subarrays of 1 3 4 7 9 6 11 of length at least 2 contain EXACTLY one even value?

  1. A. 15
  2. B. 19
  3. C. 4
  4. D. 13

Correct answer: D. 13

Count evens in each block and require exactly one; the length-at-least-two rule removes the singleton even block. Allowing any count of evens, or counting odd singletons instead, gives a different total.

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

Exams that ask this topic