Data Structures & AlgorithmsVery hardProduct Company SDE · ICPC regional

Problem: Ship packages in order (weights 4, 7, 2, 9, 5, 3, 8, 6, 1) through consecutive days, with each day's load at most a capacity C. The goal is to deliver everything in at most 4 days. What is the minimum possible capacity C?

  1. A. 17
  2. B. 14
  3. C. 11
  4. D. 12

Correct answer: B. 14

Binary search on C from max weight 9 to the total 45: C = 14 ships [4, 7, 2] [9, 5] [3, 8] [6, 1] in 4 days, while 13 needs 5. Requiring fewer than 4 days (or 3 days) gives 17, allowing 5 days gives 11, and ceil(45 / 4) = 12 ignores that packages cannot be split.

More Coding Interview Problems questions

Exams that ask this topic