LeetCode 416: Partition Equal Subset Sum, from the Half-Sum Target to Backward 0/1 Knapsack
Problem Requirements Given an array nums containing only positive integers, determine whether all its elements can be split into two subsets whose sums are equal. Input and Output Input: an integer array nums Output: return True if the array can be split equally; otherwise, return False Every element must belong to exactly one of the two subsets. No element may be discarded or used twice Examples Input: nums = [1,5,11,5] Output: True Explanation: [1,5,5] and [11] both have a sum of 11 Input: nums = [1,2,3,5] Output: False Explanation: the total is 11, and an odd total cannot be split equally Input: nums = [1,1] Output: True Explanation: put one 1 in each subset Constraints According to the LeetCode 416 statement: ...