Problem of the day
Input: ‘N’ = 3 ‘ARR’ = [1, 2, 3]
Output: 2
In the First operation we can increase the numbers at index 0, and 1 by 2 which makes the array [3, 4, 3].
In the second operation we increase the numbers at index 0 and 2 by 1 which makes all the elements to [4, 4, 4].
It is the optimal answer and there is no other optimal solution.
The first line contains ‘T’, denoting the number of test cases.
The First line of each test case contains three integers ‘N’.
The Second line contains ‘N’ numbers representing elements of the ‘ARR’.
Return minimum number of operations required to make all the elements of the array equal.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= N <= 10^4
1 <= ARR[i] <= 10^3
Time Limit: 1 sec
2
3
1 2 3
5
5 5 5 5 5
##### Sample Output 1 :
2
0
For the first test case:-
In the First operation we can increase the numbers at index 0, and 1 by 2 which makes the array [3, 4, 3].
In the second operation, we increase the numbers at index 0 and 2 by 1 which makes all the elements [4, 4, 4].
It is the optimal answer and there is no other optimal solution.
For the second test case:-
All the elements of the array are already equal so there is no operation required.
2
10
13 15 9 7 12 7 12 11 6 12
7
12 7 12 14 8 6 14
16
12