Simple yes case
Input
[1, 5, 11, 5]
Output
True
The array can be partitioned into [1,5,5] and [11], both sum to 11.
Full lesson preview
Determine whether an array of positive integers can be split into two subsets with equal sum (the Partition problem).
Problem statement
Task
Examples
Input
[1, 5, 11, 5]
Output
True
The array can be partitioned into [1,5,5] and [11], both sum to 11.
Input format
Output format
Constraints
Samples
Input
[1, 2, 3, 5]
Output
False
Total sum is 11 (odd), so can't partition into equal subsets.