561. 数组拆分 I

题目python

pythonspa

class Solution: def arrayPairSum(self, nums): """ :type nums: List[int] :rtype: int """ nums.sort() return sum(nums[::2]) 

思路:code

这道题,首先要意识到将list排序后,两两组合就能够获得相应的结果。blog

相关文章
相关标签/搜索