Allocate Minimum Number of Pages
Assign every book, in order, to exactly students learners. Each learner must receive at least one book, and each learner's books must form one contiguous…
Assign every book, in order, to exactly `students` learners. Each learner must receive at least one book, and each learner's books must form one contiguous segment. Return the minimum possible value of the largest page total assigned to any learner. Return `-1` when there are more learners than books.
- `1 <= pages.length <= 100` - `1 <= students <= 100` - `1 <= pages[i] <= 10^4`
Example 1: input pages = [12,34,67,90], students = 2; output 113. Splitting after 67 gives loads 113 and 90; no two contiguous groups have a smaller maximum.
Example 2: input pages = [10,20], students = 3; output -1. Three learners cannot each receive a non-empty allocation from two books.
Category: Binary Search. Topic: binary-search. Difficulty: Hard. Patterns: binary-search-on-answer, greedy.