Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

The array [5, 3, 8, 6, 2] must be split into exactly 2 contiguous groups, minimising the largest group sum. What is that minimum?

  1. A. 17
  2. B. 15
  3. C. 10
  4. D. 16

Correct answer: D. 16

Binary search the cap and check that the groups fit. The optimal split is [5, 3, 8] and [6, 2] with largest group 16 or [5, 3] and [8, 6, 2] with 16, and no cut gives less.

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

Exams that ask this topic