Allocate Minimum Pages
Split an array of book page-counts among k students, contiguous books each, minimizing the maximum pages any student reads.
Intuition
Flip the question: 'can we split so nobody exceeds cap X?' is easy to check greedily, and it's monotone in X. Binary search the smallest workable cap. This min-max-split pattern also solves Split Array Largest Sum and Capacity to Ship Packages.
Approach
The feasibility check
Sweep books, packing greedily; open a new student when the current one would exceed the cap. Feasible iff students used ≤ k.
Monotone → binary search
A bigger cap never needs more students. Search caps between max(book) and sum(books).
Converge on the minimum
Feasible → try smaller (hi = mid); infeasible → need bigger (lo = mid+1). lo ends at the optimum.
Solution & live demo
Edge cases
Classic GFG version returns −1; every student needs a book.
Only the full sum works — the search converges to it.