Skip to content
Onsite

Partition Equal Subset Sum

MediumP2Coding

Return true if the array nums of positive integers can be split into two groups (every element in exactly one group) with the same sum, otherwise false.

Example 1

Input
nums = [1,5,11,5]
Output
true
Why
[1, 5, 5] and [11] both sum to 11.

Example 2

Input
nums = [1,2,3,5]
Output
false

Example 3

Input
nums = [1]
Output
false

Constraints

  • 1 <= nums.length <= 200
  • 1 <= nums[i] <= 100

Hints

Run checks the 3 visible tests, Submit all 11.