Data Structures & AlgorithmsHard

How many contiguous subarrays of 2 5 1 2 4 7 have length at least 2, contain pairwise DISTINCT values, and have an ODD sum?

  1. A. 6
  2. B. 9
  3. C. 12
  4. D. 7

Correct answer: A. 6

Three tests must hold on the same block: length at least 2, all values different, and an odd total. Dropping the singleton rule or the distinctness rule, or flipping the parity, each changes the count.

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

Exams that ask this topic