Dsa
Greedy
Medium
Charitable Donations
You are given a list of donations, where each donation represents the amount of money a charity can receive. Your goal is to distribute these donations among `k` different charities in such a way that the minimum donation any charity receives is maximized. Write a function that takes a list of donations and an integer `k`, and returns the maximum minimum donation that can be achieved.
Input:
The first line contains an integer `n` (1 ≤ n ≤ 100), the number of donations.
The second line contains `k` (1 ≤ k ≤ n), the number of charities.
The third line contains `n` integers, where each integer represents the amount of a donation (0 ≤ donations[i] ≤ 1000).
Output:
Return the maximum minimum donation possible.
Example:
Input:
5
3
10 7 5 8 15
Output:
8
In this example, you can distribute the donations as {10, 7, 15} to charity 1, {8, 5} to charity 2, resulting in a minimum donation of 8.
Key concepts
greedysortingoptimization
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