Book Allocation Problem

00:00
MediumArrayBinary SearchGreedy
AmazonAdobe

Allocate M books among K students such that maximum number of pages assigned to any student is minimized. Books must be allocated in contiguous order.

Examples

Input → books=[12,34,67,90], K=2
Output → 113
Note: split as [12,34,67] and [90]: max=113 or [12,34] and [67,90]: max=157, so min max=113
Input → books=[10,20,30,40], K=2
Output → 60
Input → books=[15,17,20], K=2
Output → 32