Data Structures & AlgorithmsHardGATE CS · ICPC regional

What is the sum of the minimum value of every contiguous window of length 3 in the array [4, 2, 12, 11, -5, 3, 7]?

  1. A. -11
  2. B. -14
  3. C. 54
  4. D. -9

Correct answer: A. -11

Enumerate the five windows and take each minimum: 2, 2, -5, -5, -5. Summing the window maxima (12, 12, 12, 11, 7 = 54) is a classic mix-up.

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

Exams that ask this topic