You are given an array of 'n' numbers. A move is defined by choosing 'n-1' numbers and increasing their value by 1. Find the minimum number of moves you need to make all the numbers equal for that array.
For example: [1, 2, 3]
- Choose : [1(0), 2(1)] and array become [2, 3, 3]
- Choose : [2(0), 3(1)] and array become [3, 4, 3]
- Choose : [3(0), 3(2)] and array become [4, 4, 4]
return sum(arr) - min(arr)*len(arr)
How did you arrive at this solution, and would you mind explaining some of the intuition behind it? Thanks!
@benjie I will try to explain from where the formule comes. Pls, take a look at the picture to get some initial idea.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.