by hackcasual · 5y ago · 0 comments
1. Spilt the toys in two sets (A and B) of similar size.
2. Generate a sorted list L of all the possible sums that can be made with the toys in set A. If two sums are equal, keep only one.
3. Generate a sorted list M of all the possible sums that can be made with the toys in set B. If two sums are equal, keep only one.
4. Iterate through L forwards and through M backwards looking for two sums that together make up the target amount.
https://en.wikipedia.org/wiki/Knapsack_problem#Meet-in-the-m...