Tuesday, February 7, 2012

All combinations of numbers that can compose a given number

Given a target number, and a series of candidate numbers, print out all combinations, so that the sum of candidate numbers equals to the target.

Here order is not important, so don’t print the duplicated combination.
e.g. target is 7, candidate is 2,3,6,7
output should be 7 and 3+2+2 (but not print 2+3+22+2+3)

No comments:

Post a Comment