Fair Split
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
0 <= len(nums) <= 10-50 <= nums[i] <= 50
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Recursion problems
- Fill In the BracketsMedium
- Hidden Word CountMedium
- Maze EscapeMedium
- Numbers RoundMedium
- Tower MovesMedium
- Tower With a Middle StopMedium
- Where the Trace Can StartMedium
- Crates of Equal WeightHard