Greedy String / Binary Search Problem

Problem A greedy string-construction or binary-search-on-answer problem: find the smallest (or largest) value satisfying a monotonic feasibility predicate. A canonical framing: given package weights that must ship in order and D days, find the minimum ship capacity so all packages ship within D days.

Input / Output

  • Input: the problem parameters (e.g. weights array and D).
  • Output: the boundary value satisfying the predicate.

Constraints

  • The feasibility check is monotonic: if a value works, every larger value also works.

Example

  • weights=[1,2,3,4,5,6,7,8,9,10], D=5 → minimum capacity 15.
added …
LeaderboardSalaryAccount