views:

164

answers:

1

There is a bag that can take X kilogram. You will get an array of stuff and their weight. Print true and the each weight of the stuff and false if there is no answer

Example:

for X=20
array {4,9,1,15,7,12,3}
print true and 4 1 15 (4+1+15=20)
+2  A: 

This is a variation of subset sum problem.

You can find some guidelines of approaching this using backtracking here.

codaddict