Question bank › Greedy
Dsa Greedy Easy

Minimum Adjustments for Sales Target

You are a manager at a company, and you have a quarterly sales target for your team. Each team member reports their sales number, and you want to find out how many adjustments (increases or decreases) are needed to reach the exact sales target. You can only make adjustments to the members to achieve the target without exceeding it. Write a function that takes as input the sales target and a list of sales from team members. The output should be the minimum number of adjustments needed to ensure the total sales equals the target. If it's not possible to reach the target, return -1. Input: - The first line contains an integer `target` (0 <= target <= 10000). - The second line contains an integer `n` (1 <= n <= 100), the number of sales members. - The third line contains `n` space-separated integers (0 <= sales[i] <= 1000) representing each member's sales. Output: - An integer representing the minimum number of adjustments needed or -1 if it's impossible to meet the target. Example: Input: 100 3 30 50 20 Output: 1 In this case, you can increase the sale of the member with sales 20 to 30.

Key concepts

greedyarraycumulative

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.