Question bank › Greedy
Dsa Greedy Medium

Gift Distribution Optimization

You are organizing a gift distribution event where each gift has a different value, and you have a budget to spend. You want to maximize the total value of the gifts you can afford without exceeding your budget. Gifts can be purchased individually and you cannot split a gift's value. Input Format: - The first line contains an integer `n` (the number of gifts) and an integer `budget`. - The next `n` lines contain the value of each gift. Output Format: - Print the maximum total value of gifts you can buy within the budget. Example: Input: 5 10 2 1 3 5 4 Output: 10

Key concepts

greedysortingarrays

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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.