Data Structures & AlgorithmsHardGATE CS · competitive programming

Treat [5, −3, 5] as a circle. What is the maximum sum of a non-empty contiguous subarray, where the subarray may wrap around the end?

  1. A. 10
  2. B. 7
  3. C. 5
  4. D. 2

Correct answer: A. 10

Wrapping lets you take both 5s, at indices 2 and 0, for 10. Plain Kadane on the line gives 7 (the whole array), which misses the wrap.

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

Exams that ask this topic