Problem Description
Given an integer array A of size N, you are asked to make all the elements of the array equal by performing the following operation minimum number of times.
Return the minimum number of operations required.
1 <= N <= 105
0 <= A[i] <= 109
First and only argument is an integer array A of size N.
Return the minimum number of operations required.
Input 1:
A = [10, 1, 4, 2]
Input 2:
A = [5, 7, 4, 3, 5]
Output 1:
5
Output 2:
4
Explanation 1:
We will make all the values equal to 2 or 0 so that the operations required are minimum, i.e 5.
Explanation 2:
We will make all the values equal to 5 so that the operations required are minimum, i.e 4.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.