Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Bi-directional subset sum problem


This is my first post, and I have been stuck with this problem for a while now so I was wondering if any of you guys might be able to help or know a good place for me to go and do some more investigation myself.

Here's the problem:
I have 2 lists of integer numbers (list A and list B) and am looking for subsets within each whose sums match. The numbers can be negative, under the assumption that:
- the same number does not appear in both lists (e.g. if 4 is in list A then it doesn't exist in list B)

The problem is similar to the subset sum problem:
except that I'm looking for subsets on both sides.

Here's an example:
List A

List B

So the only match here is:
{10, 1, 4, 9} <=> {21, 7, -4}

Does anyone know if there are existing algorithms for this kinda problems?

So far, the only solution I have is a brute force approach which tries every combination but it performs in Exponential time and I've had to put a hard limit on the number of elements to consider to avoid it from taking too long.

The only other solution I can think of is to run a factorial on both lists and look for equalities there but that is still not very efficient and takes exponentially longer as the lists get bigger..

Any help will be much appreciated!



Sign In or Register to comment.