FunctionRacerProblemsRace

Fair Split

MediumRecursionPython, JavaScript, TypeScript, Java, C++

Return True if the integers in nums can be divided into two groups with equal sums, using every element exactly once, and False otherwise. A group may be empty: [0] can be split (one group holds the 0, the other is empty, both sum to 0), and an empty nums splits into two empty groups. Values may be negative, so [3, -3] can be split too: both numbers go into one group, which sums to 0, and the other group is empty.

Example 1

nums [1,5,11,5]
returns true

[1, 5, 5] and [11] both sum to 11.

Example 2

nums [1,2,3,5]
returns false

The total is 11, which is odd, so no two groups can have the same sum.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Recursion problems