Simple Js functional solution


  • 0
    C
    var minMoves = function(nums) {
        var min = nums.reduce((a, b) => Math.min(a, b), nums[0]);
        return nums.reduce((a, b) => a + b - min, 0);
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.