ruby solution


  • 0
    S

    this is more about thoughts rather than coding, put my ruby solution here.

    def array_pair_sum(nums)
      nums.sort!
      result = 0
      nums.each_with_index do |element, index|
        result += element if index % 2 == 0
      end
      result
    end
    

Log in to reply
 

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