Two friends want to share a bag of sweets fairly. Each sweet i has a weight nums[i], and a sweet cannot be cut.
Check if the sweets can be split into two groups so that both groups have the same total weight. Every sweet must go to exactly one group.
Return true if this is possible and false if it is not.
Examples
Example 1:
Input: nums = [3,3,6,2,2]
Output: true
Explanation: The total is 16. Group {6, 2} and group {3, 3, 2} both weigh 8.
Example 2:
Input: nums = [2,5,9]
Output: false
Explanation: The total is 16, so each group needs 8. No choice of sweets adds up to 8.
Example 3:
Input: nums = [4,4]
Output: true
Explanation: One sweet in each group, both weigh 4.