Dsa
Greedy
Easy
Book Allocation
In a library, you are tasked with allocating a certain number of books to students based on their reading capacities. Each student can read a certain number of books, and your job is to maximize the total number of books allotted without exceeding each student's capacity. The input contains an integer representing the total number of students, followed by a list of integers for each student's reading capacity. Your task is to output the total number of books that can be allocated. Example input:
3
2 3 5
Output:
10
Key concepts
greedyallocationbooks
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