Dsa
Arrays
Medium
Equally Distributed Integers
Given an array of integers, find out if it is possible to rearrange the elements so that every integer appears an equal number of times, and if so, output the minimum number of moves required to achieve this configuration.
Input:
- The first line contains an integer n, the number of elements in the array (1 ≤ n ≤ 100).
- The second line contains n space-separated integers representing the elements of the array.
Output:
- A single integer representing the minimum number of moves required to evenly distribute the integers, or -1 if it is not possible.
Example:
Input:
6
1 2 1 2 3 3
Output:
0
Key concepts
arraysdistributioncounting
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