Javascript 1 line solution


  • 0
    M
    /**
     * @param {number[]} nums
     * @return {number}
     */
    var arrayPairSum = function (nums) {
        return nums.sort((a, b) => a - b)
                   .filter((ele, index) => index % 2 == 0)
                   .reduce((prev, current) => prev + current, 0);
    };
    

Log in to reply
 

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