Data Structures & AlgorithmsModerateTCS NQT · Codeforces Div2 B

Among the windows of exactly 3 consecutive elements of [5, 2, 9, 1, 7, 3, 8, 4], what is the smallest window sum that is at least 15?

  1. A. 18
  2. B. 16
  3. C. 11
  4. D. 15

Correct answer: D. 15

Window sums are 16, 12, 17, 11, 18, 15; those ≥ 15 are 16, 17, 18 and 15, so the smallest is 15. Stopping at the first qualifying window gives 16, the largest sum is 18, and 11 is the smallest sum overall, below the threshold.

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

Exams that ask this topic