#C3199. Minimum Removals to Make Array Simple
Minimum Removals to Make Array Simple
Minimum Removals to Make Array Simple
You are given an array of integers and your task is to remove the minimum number of elements so that the resulting array becomes simple, i.e., each element appears exactly once. Formally, let (n) be the total number of elements in the array and (|D|) be the number of distinct elements. Then the minimum number of removals is given by:
(\text{removals} = n - |D|).
The input consists of multiple test cases. For each test case, compute and print the required number of removals.
inputFormat
The first line contains a single integer (T) denoting the number of test cases. Each test case consists of two lines. The first line contains an integer (n) representing the number of elements in the array. The second line contains (n) space-separated integers.
outputFormat
For each test case, output a single integer on a new line representing the minimum number of elements that need to be removed to make the array simple.## sample
3
5
1 2 2 3 4
6
5 5 5 5 5 5
4
1 2 3 4
1
5
0
</p>