python (65.2k questions)
javascript (44.3k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (13k questions)
Recursively finding subset sum
I am practicing on recursion and i wanted to try a very popular problem for recursion, the subset sum problem, but i wanted a little catch. I also want to print the subset if it exists.
#include <s...
xKostmand
Votes: 0
Answers: 0
randomly find a combination from an array with duplicate elements and it's sum equal n
How can I randomly find a combination from an array with duplicate elements and it's sum equal n.
Example
array is [1, 2, 2, 3] and n is 3
answers are 1+2, 1+2, 3
If randomSubsetSum(array, n) is solu...
xmcx
Votes: 0
Answers: 1
Subset sum problem using key value pairs - python
I have an algorithm that outputs a subset which sums up to a value as close to integer s as possible
from itertools import combinations
products = {
"Apple": 5,
"Pear": 4,...
Aleksander Szczepaniak
Votes: 0
Answers: 1
Number of subsets with a given sum . Recursion not tracing few branches of the tree
I have written this code in python and it is not yielding the right answer for the input wt[]=[2,3,5,6,8,10] in this order . It is giving right answer for few other combinations like wt[]=[3,2,6,10,8,...
IPSITA MAZUMDER-110
Votes: 0
Answers: 1