Array Partition
nums has an even number of items. Split it into pairs (every item used exactly once). The score of a pair is its smaller number, and the score of a split is the sum of its pair scores.
Return the largest score you can get from any split.
Example 1
nums [1,4,3,2]
returns 4
Pair (1,2) and (3,4): 1 + 3 = 4.
Example 2
nums [6,2,6,5,1,2]
returns 9
Pair (1,2), (2,5), (6,6): 1 + 2 + 6 = 9.
Constraints
2 <= len(nums) <= 20len(nums)is even.
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.