Equal Difference solution codechef
You are given an array ofintegers. Find the minimum number of integers you need to delete from the array such that the absolute difference between each pair of integers in the remaining array will become equal.
Input Format Equal Difference solution codechef
- The first line of input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains an integer .
- The second line of each test case contains space-separated integrs .
For each test case, print a single line containing one integer – the minimum number of integers to be deleted to satisfy the given condition.
- Sum of over all test cases does not exceed .
Sample Input 1
3 2 1 2 5 2 5 1 2 2 4 1 2 1 2
Sample Output 1 Equal Difference solution codechef
0 2 2
Test case: There is only one pair of integers and the absolute difference between them is . So there is no need to delete any integer from the given array.
Test case: If the integers and are deleted, the array A becomes and the absolute difference between each pair of integers is . There is no possible way to delete less than two integers to satisfy the given condition.