ALG-M018MediumDynamic Programming
Equal Load Split
Return true if the nonnegative values can be divided into two groups with exactly the same sum. Every input element must belong to one group.
Contract
input numbers: integer[]
return boolean
Constraints
- • All values >= 0
- • 0 <= length <= 200
- • Sum <= 20000
Examples
Example 1
numbers = [1, 5, 11, 5]
→ true
Example 2
numbers = [1, 2, 3, 5]
→ false
5 judge tests (2 shown above). Target complexity: O(n * total_sum).