Dsa
Greedy
Warm-up
Budget Allocation
You are given a list of project costs and a total budget. Your task is to determine the maximum number of projects that can be completed within the budget. Input will be provided as the first line containing an integer n (the number of projects) followed by n integers (the costs of each project) in the next line, and the final line will contain an integer representing the total budget. Output the maximum number of projects that can be completed within the budget.
Example:
Input:
5
10 20 30 40 50
100
Output:
4
Key concepts
greedyarraysorting
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