Javascript Solution


  • 0
    E
    const arrayPairSum = nums => {
        const arr = nums.sort((x, y) => x - y);
        let sum = 0, len = arr.length, i = 0;
        for (; i < len; i+=2) {
            sum += arr[i];
        }
        return sum;
    };
    

Log in to reply
 

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