Given an integer array nums with an even number of elements, divide it into n pairs so that each element belongs to exactly one pair. For each pair, take the smaller value, and return the largest possible sum of these smaller values.
Note:
nis half the length ofnums.
Constraints:
n
nums.length
nums[i]
Given an integer array nums with an even number of elements, divide it into n pairs so that each element belongs to exactly one pair. For each pair, take the smaller value, and return the largest possible sum of these smaller values.
Note:
nis half the length ofnums.
Constraints:
n
nums.length
nums[i]