Question bank › Dynamic Programming
Dsa Dynamic Programming Medium

Balanced Budget Planner

You are planning a budget for an upcoming project that has multiple expense categories. Each category has a fixed limit, and any expenses exceeding that limit will incur penalties. Given a list of expenses and their respective limits, determine the minimum total penalties incurred based on your expense allocations. You can only allocate expenses in such a way that they do not exceed the limits of the categories. Input format: - The first line contains an integer m (number of categories). - The second line contains m space-separated integers (expense limits). - The third line contains an integer n (number of expenses). - The fourth line contains n space-separated integers (expenses). Output format: - A single integer representing the minimum total penalty incurred. Example: Input: 3 100 200 150 5 60 90 100 70 80 Output: 10

Key concepts

dynamic_programminggreedy

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.