Array Partition I
class Solution:
def arrayPairSum(self, nums: List[int]) -> int:
nums.sort() # 小到大排序
result = 0
for i in range(0, len(nums), 2): # 兩兩一組,取每組的第一個數字
result += nums[i]
return result
Reference: