Data Structures & AlgorithmsHardGATE CS · TCS NQT

What is the sum of the minimum of every contiguous window of length 2 in the array [3, 1, 4, 1, 5, 9, 2, 6]?

  1. A. 14
  2. B. 10
  3. C. 13
  4. D. 15

Correct answer: C. 13

Each window of length 2 contributes its smaller element; the window minimum of adjacent pairs is min(a[i], a[i+1]). Summing the larger values instead is the common slip.

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

Exams that ask this topic