Partition Equal Subset Sum
Given an array nums of positive integers, decide whether it can be split into two groups with the same sum. Every element must go into exactly one of the two groups.
Return true if such a split exists and false otherwise.
Constraints
1 <= nums.length <= 2001 <= nums[i] <= 100
Examples
Example 1
Input: nums = [3,1,4,2,2] Output: true
[4, 2] and [3, 1, 2] both sum to 6.
Example 2
Input: nums = [1,2,5] Output: false
The total is 8, so each group needs 4, and no subset adds up to 4.
Example 3
Input: nums = [1,2,4] Output: false
The total, 7, is odd: two equal halves are impossible.
JavaScript you'll use: Iterating and transforming arrays Arrays: create, read, update
/**
* @param {number[]} nums
* @return {boolean}
*/
function canPartition(nums) {
}
Ctrl/⌘ + ' runs the examples, Ctrl/⌘ + Enter submits. Use console.log freely: output shows under Console. In the editor, press Esc then Tab to move focus out.