// Minimum Moves to Equal Array Elements

// Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal,
// where a move is incrementing n - 1 elements by 1.

// Example:

// Input:
// [1,2,3]

// Output:
// 3

// Explanation:
// Only three moves are needed (remember each move increments two elements):

// [1,2,3]  =>  [2,3,3]  =>  [3,4,3]  =>  [4,4,4]

/**
 * @param {array[]} nums
 * @return {number}
 */



@@ -462,9 +462,413 @@
 r%7D%0A */%0A%0A
+// ---------- TIME LIMIT EXCEEDS OVER 9,999,999 STEPS%0A%0Avar minMoves = function(nums) %7B%0A    var incr = nums.length -2,%0A        lowVal,%0A        index,%0A        steps = 0;%0A%0A    function sameVals(arr)%7B%0A        return arr.every(x =%3E x === arr%5B0%5D);%0A    %7D%0A    while( !sameVals(nums) )%7B%0A        index = nums.indexOf( Math.min.apply(null, nums) );%0A        nums%5Bindex%5D++;%0A        steps++;%0A    %7D%0A    return steps;%0A%7D;
 %0A

add first solution --- does not pass large cases