Bi-directional subset sum problem - Programmers Heaven

#### Howdy, Stranger!

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

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Bi-directional subset sum problem

Posts: 1Member
Hi,

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 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

The problem is similar to the subset sum problem:
http://en.wikipedia.org/wiki/Subset-sum_problem
except that I'm looking for subsets on both sides.

Here's an example:
List A
4
5
9
10
1

List B
21
7
-4
180

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!

Thanks,

Yan