Subset Sum Problem (Dynamic Programming)

preview_player
Показать описание
Question: Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given sum

Input: set[] = {3, 34, 4, 12, 5, 2}, sum = 9
Output: True
There is a subset (4, 5) with sum 9

#subsetsum #dp #netsetostech
Комментарии
Автор

This is probably best explanation solving completely instead of saying so on and so forth

midhileshmomidi
Автор

Hi, I understood the algorithm, but how can I return the values of all the subsets that sum up to the value ?
For example:
array = [ 1, 2, 3, 4, 5, 6]
num=6
subsets(array, num) = [ [ 1, 5 ], [ 2, 4 ] ]

pedroadrianpereiramartinez