Question bank › Greedy
Dsa Greedy Easy

Resources Distribution

You are given a list of resources with associated demand numbers and capacities. Your task is to allocate the resources to fulfill the demands in such a way that you can maximize the total satisfied demand. Each resource can satisfy a single demand only. Input format: - The first line contains an integer r (1 ≤ r ≤ 100) - the total number of resources. - The second line contains r integers, representing the capacities of each resource. - The third line contains an integer d (1 ≤ d ≤ 100) - the total number of demands. - The fourth line contains d integers, representing the demands. Output format: - A single integer representing the maximum satisfied demand. Example: Input: 5 3 4 2 5 1 3 2 3 4 Output: 7

Key concepts

greedydistributionsorting

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