Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
It's pretty much subset sum problem but slightly modified.

There is a set A of integers, without limits to length of both set and integers (they can be so big that only BigInteger can contain them). And there is a target integer.

Algorithm needs to find if set A contains any subset (subset can be the set) that can be summed up to target integer, and display that set.

So for set 1,2,3 and target 5 answer true: 2,3 would be correct. Answer true: 1,1,1,1,1 would be incorrect - set 1,1,1,1,1 is not a subset of 1,2,3.

Considering size of the data recursive solution is not an option.

What I have tried:

There is plenty of solutions for subset sum problem online but none of them seems to be possible to modify to this problem.
Posted
Updated 15-Mar-22 0:41am

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

Start with a piece of paper and work out a method of doing it. Then think about what effect the size of the set will have on that method, and why. "Finding a solution that works for you" is part of the task - not "Finding a solution online"!

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
 
Share this answer
 
Comments
Member 15047625 15-Mar-22 6:48am    
This is solution for subset sum problem. I'm unsure how to convert it to my problem, and I hoped someone has any ideas.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900