subset-sum Questions
7
Solved
I have a list of numbers, e.g.
numbers = [1, 2, 3, 7, 7, 9, 10]
As you can see, numbers may appear more than once in this list.
I need to get all combinations of these numbers that have a given...
Jordison asked 29/12, 2015 at 19:14
7
Here maximum sum subset is one of k subsets that give maximum sum
e.g: arr = [10,5,3,7] and k = 2
possible ways to divide arr in k subsets is
{10,[5,3,7]},{[10,5],[3,7},{[10,5,3],7}
and
{[10,5],[...
Vineyard asked 24/9, 2016 at 7:47
5
Solved
This problem was asked to me in Amazon interview -
Given a array of positive integers, you have to find the smallest positive integer that can not be formed from the sum of numbers from array.
Ex...
Conjunctiva asked 12/1, 2014 at 17:19
6
Solved
Given an array we need to find out the count of number of subsets having sum exactly equal to a given integer k.
Please suggest an optimal algorithm for this problem. Here the actual subsets are no...
Spoofery asked 6/4, 2014 at 7:17
7
Solved
I am trying to write a function that will not only determine whether the sum of a subset of a set adds to a desired target number, but also to print the subset that is the solution.
Here is my co...
Lenlena asked 15/4, 2014 at 15:13
1
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 s...
Heptameter asked 4/3, 2022 at 14:37
4
Solved
I have an array with some integer values, and I need to get a subset of them that gives me the maximum sum that is inferior to a given value.
So let's say I have this array:
[40, 138, 29, 450]
I...
Scallop asked 19/12, 2017 at 17:9
8
Solved
Let's say I want to find all sets of 5 single-digit, non-repeating numbers that add up to 30... I'd end up with [9,8,7,5,1], [9,8,7,4,2], [9,8,6,4,3], [9,8,6,5,2], [9,7,6,5,3], and [8,7,6,5,4]. Eac...
Avigation asked 4/5, 2010 at 1:46
3
Solved
How to find a subset of numbers from 2 to 1000 that will give you the max sum under the condition that any two numbers from the subset don't share common prime factors (e.g., 1000 and 500 share the...
Kimber asked 17/11, 2017 at 10:34
2
Solved
So, I have this problem I need to solve, apparently this is called Subset Sum Problem, except I need to get the subset not only when is exact to the given number, but the closest in case there is n...
Futility asked 22/3, 2021 at 21:6
5
Solved
Lets say we have an array of positive numbers and we were given a value M. Our goal is to find if there is a consecutive sub sequence in the array of positive numbers such that the sum of the seque...
Rafaelrafaela asked 24/2, 2016 at 16:43
32
Solved
How would you go about testing all possible combinations of additions from a given set N of numbers so they add up to a given final number?
A brief example:
Set of numbers to add: N = {1,5,22,15...
Faruq asked 8/1, 2011 at 4:26
1
Solved
I've been learning python for my hobby and empirical research into NP-complete problems such as Subset Product. The algorithm I have works, but it's not doing it the way I intend to do.
What I'm t...
Trafalgar asked 19/11, 2019 at 2:14
12
Solved
I am working on this problem:
The Subset Sum problem takes as input a set X = {x1, x2 ,…, xn} of n integers and another integer K. The problem is to check if there exists a subset X' of X whose ...
Pam asked 4/12, 2010 at 21:34
5
Solved
I've seen a few solutions to similar problems, but they all require iteration over the number of items to be added together.
Here's my goal: from a list of numbers, find all of the combinations (w...
Heliozoan asked 9/11, 2018 at 23:26
0
I'm going through an exercise to partition a set into K subsets with equal sum.
Let's say
Input : arr = [2, 1, 4, 5, 6], K = 3
Output : Yes
we can divide above array into 3 parts with equal
sum a...
Gopak asked 29/11, 2017 at 16:49
7
Solved
I had the following question in an interview and, in spite of the fact that I gave a working implementation, it wasn't efficient enough.
A slice of array A is any pair of integers (P, Q) such t...
Aerography asked 17/5, 2013 at 9:43
6
Solved
recently I became interested in the subset-sum problem which is finding a zero-sum subset in a superset. I found some solutions on SO, in addition, I came across a particular solution which uses th...
Topic asked 16/5, 2011 at 3:39
2
Assume you have two piles, each made of N boxes of different heights. You want to remove boxes so as to obtain two piles of equal heights (if possible). You cannot remove a box which is not at the ...
Heiner asked 3/5, 2017 at 7:30
1
Solved
I have written a code to find Sum of product of all possible subsets of array. I'm getting the expected output but I'm not able to make it fast enough to clear time related test cases.
Can anyone...
Pedology asked 24/3, 2017 at 7:14
2
Solved
I have 2 sets, set A contains set of random numbers and set B's elements are sum of set A's subsets.
For example,
A = [8, 9, 15, 15, 33, 36, 39, 45, 46, 60, 68, 73, 80, 92, 96]
B = [183, 36, 231...
Vltava asked 23/2, 2017 at 17:56
3
Solved
Consider vector s as follows:
s=seq(0.01, 0.99, 0.01)
> s
[1] 0.01 0.02 0.03 0.04 0.05 0.06 0.07
0.08 0.09 .......... 0.89 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99
Now given s and...
Cavefish asked 7/6, 2016 at 18:30
3
Solved
What I want to do
I want to find a subset of an array that sums to a target T. I also want to use to a dynamic programming approach (and a bottom-up solution at that) to do this.
What I currentl...
Amalberga asked 15/9, 2013 at 23:10
1
I have a positive integer array-
{1,5,8,2,10} and a given value 7.
I need to find whether a subset of the array exists such that the XOR of its elements is the value 7.
In this case the subset is {...
Jin asked 6/12, 2014 at 14:20
7
I've been struggling with level 3 of the Greplin challenge. For those not familiar, here is the problem:
you must find all subsets of an array where the largest number is the sum of the remaining ...
Twister asked 15/6, 2011 at 4:59
1 Next >
© 2022 - 2024 — McMap. All rights reserved.