Data Structures & AlgorithmsHardProduct company OA · Amazon/Microsoft-style OA

Split the array [7, 2, 5, 10, 8, 4, 6] into 3 non-empty contiguous parts so that the largest part sum is as small as possible. What is that minimum possible largest sum?

  1. A. 21
  2. B. 16
  3. C. 10
  4. D. 18

Correct answer: D. 18

Binary search on the answer: a cap works when a greedy left-to-right split needs at most 3 parts, and the feasibility test is monotone in the cap. Splitting by equal counts instead of equal sums gives a larger maximum.

More Coding Interview Problems questions

Exams that ask this topic