Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional

Treat [4, -1, 5, -6, 3] as circular. Over all contiguous circular windows of length 1 to 5, what is the maximum window sum?

  1. A. 11
  2. B. 12
  3. C. 5
  4. D. 8

Correct answer: A. 11

A circular window of length L starts at any index and wraps around. Brute force over starts and lengths is O(n^2) and enough here; the answer uses the wrap from index 4 back to 0.

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

Exams that ask this topic