Given an array nums of positive integers, return true if you can split it into two groups with the same sum, and false otherwise.
Every number goes into exactly one of the two groups.
Examples
Example 1
Input: nums = [1,5,11,5]
Output: true
[1,5,5] and [11] both add up to 11.
Example 2
Input: nums = [1,2,3,5]
Output: false
The numbers add up to 11. An odd total can't be split into two equal halves.
Example 3
Input: nums = [1,2,5]
Output: false
The total is 8, so each group would have to add up to 4. No group of these numbers does: the possible sums are 1, 2, 3, 5, 6, 7 and 8. An even total isn't enough on its own.
Example 4
Input: nums = [3,3,2,2,2]
Output: true
[3,3] and [2,2,2] both add up to 6. Handing out the biggest numbers first, each to the group with the smaller sum, puts the two 3s in different groups and ends at 7 and 5, so that approach would wrongly say false.
Example 5
Input: nums = [7]
Output: false
One group gets the 7 and the other gets nothing, so the sums are 7 and 0.
Constraints
1 <= nums.length <= 2001 <= nums[i] <= 100