Algorithms Playbook
← All problems
MediumKnapsack →Similar to: Partition Equal Subset Sum

Two piles, same total

Problem

Given an array of positive integers, return whether it can be split into two subsets whose sums are equal.

Examples

Input: [1, 5, 11, 5]

Output: true

[1, 5, 5] and [11].

Input: [1, 2, 3, 5]

Output: false

Hints

    Try it first. Every hint reveals a bit more.

    Solution