Intuitive Javascript Solution


  • 0
    D
    var arrayPairSum = function(nums) {
        // sort and sum up the minimum of the pairs
        return nums
            .sort((a, b) => a - b)
            .reduce((sum, cur, i) => (i % 2 === 0) ? sum += cur : sum, 0);
    };
    

Log in to reply
 

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