Data Structures & AlgorithmsHard

How many contiguous subarrays of 4 2 3 6 5 7 1 have length equal to (maximum − minimum + 1)?

  1. A. 14
  2. B. 8
  3. C. 0
  4. D. 15

Correct answer: A. 14

If length equals spread plus one, the values of the block cover a full range with no gaps or duplicates. Shifting the formula by one changes the qualifying set.

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

Exams that ask this topic