The Minimum Number Of Moves | CodeChef

can anyone explain approach for this problem

Let temp_max is the maximum number in the array and temp_min be the minimum number.
In each iteration check for the values of temp_max and temp_min in the array .
Then add the difference of temp_max and temp_min in each element of the array except to the number whose value is temp_max i.e. the maximum number.
Do this until all elements of array become equal .
Complexity = O(n2)
Link = CodeChef: Practical coding for everyone