开发者

Backtracking recursion question

开发者 https://www.devze.com 2022-12-16 06:12 出处:网络
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

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)


This is a variation of subset sum problem.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消