Questions tagged [subset-sum-problem]

Given a set or multiset of integers, is there a non-empty subset whose sum is zero? The subset sum problem can be extended to find the sum to any given integer. The subset sum problem is a special case of the knapsack problem.

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

Subset sum using the Horowitz-Sahni algorithm and pruning strategies

The subset sum problem asks if some subset of a set can be summed to a given number (equivalently, if they sum to 0). I recently had to implement it, under an additional restriction of all numbers ...
6
votes
3answers
102 views

Leetcode Three Sum

From here: Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The ...
0
votes
0answers
82 views

Finding if there is sub array with sum equals to 0

I have asked to write a program to find if there is a sub-array with a sum equal to zero using JavaScript. Is this a good solution? How can I improve it? ...
4
votes
1answer
83 views

Subset Sum in Ada

One of my favorite classic programming exercises is the Subset Sum problem. I'm (trying) to learn Ada and it's the first thing I wanted to implement, even before a Hello World. The Subset Sum ...
2
votes
2answers
68 views

Python set based solution to Subset Sum

Working on the 2 element subset sum problem (finding two numbers in a list that sum to a given value), I came up with a relatively short solution code-wise. The code could fit on a single line but I'...
4
votes
2answers
5k views

Finding all the subsets in an array of integers that sum to a given target

Problem Statement: Given an Array if ints, Find out all the subsets in the Array that sum to a given target value. Example: If the input array is: ...