Question bank › Arrays
Dsa Arrays Medium

Array Mean Decrement

You are given an array of integers. Your task is to find the minimum number of decrements needed to ensure that the mean of the array is less than or equal to a given threshold value t. A decrement means reducing an element by 1. Input: - The first line contains an integer n (1 <= n <= 1000), the number of elements in the array. - The second line contains n space-separated integers, the elements of the array. - The third line contains a float t (0 <= t <= 100). Output: - Print a single integer: the minimum number of decrements required to achieve the threshold mean. Example: Input: 4 10 20 30 40 25.0 Output: 45

Key concepts

arraysmean

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.