ProgrammingHardTCS NQT · Infosys

What is the largest sum of any three consecutive elements of {2, 1, 5, 1, 3, 2}?

  1. A. 8
  2. B. 9
  3. C. 7
  4. D. 6

Correct answer: B. 9

The window sums are 8, 7, 9 and 6, and the largest is 9. A fixed-size sliding window updates each sum by one addition and one subtraction.

More C Programming questions

Exams that ask this topic