Golang concise


  • 0
    A
    func arrayPairSum(nums []int) (sum int) {
        sort.IntSlice(nums).Sort()
        for i := 0; i < len(nums); i += 2 {
            sum += nums[i]
        }
        return sum
    }
    

Log in to reply
 

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