Leetcode 561. Array Partition I

class Solution:
    def arrayPairSum(self, nums: List[int]) -> int:
        nums.sort()
        ans, i = 0, 0
        while i < len(nums):
            ans += nums[i]
            i += 2
        return ans

 

posted @ 2019-04-10 04:41  周洋  阅读(128)  评论(0编辑  收藏  举报