Data Structures & AlgorithmsHard

How many contiguous subarrays of 3 3 2 4 1 2 have a sum EXACTLY equal to (their length) × (their minimum)?

  1. A. 21
  2. B. 7
  3. C. 2
  4. D. 8

Correct answer: B. 7

Equality with length times the minimum says every element equals the minimum, so the qualifying blocks are constant runs. Using the maximum, a non-strict bound, or adding one changes the total.

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

Exams that ask this topic