Data Structures & AlgorithmsVery hard

What is the MINIMUM sum of a contiguous subarray of 4 -2 1 -5 3 2 -1 whose length is at least 3?

  1. A. -5
  2. B. -3
  3. C. 4
  4. D. -6

Correct answer: D. -6

Minimum-sum subarrays are Kadane's maximum problem on negated values, with the extra length constraint enforced by prefix sums up to i−3. Allowing shorter blocks, or fixing the length at exactly three, changes the minimum.

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

Exams that ask this topic