Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

Using a monotonic deque, the window maximum for every window of size 3 over [1, 3, -1, -3, 5, 3, 6, 7] is listed left to right. What is the sum of these window maxima?

  1. A. -4
  2. B. 29
  3. C. 28
  4. D. 23

Correct answer: B. 29

Windows give maxima 3, 3, 5, 5, 6, 7 which sum to 29. The sum of window minima is a different quantity, and using window size 2 changes the list.

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

Exams that ask this topic