Dsa
Binary Search
Medium
Minimum Page Allocation
A student has to read n books with given page numbers, and can read at most k pages per day. To minimize the maximum number of pages read on any given day, write a function to find the minimum number of days required to read all the books, ensuring that the student does not exceed k pages in a single day.
Input format:
- The first line contains two integers n (1 ≤ n ≤ 10^5) and k (1 ≤ k ≤ 10^9).
- The second line contains n space-separated integers, representing the number of pages in each book.
Output format:
- Output the minimum number of days required to read all the books.
Example:
Input:
4 100
120 100 140 150
Output:
2
Key concepts
binary_searchgreedy
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now