leetcode 216. Combination Sum III Add to List (枚举子集,限定集合大小,和为定值)

Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.

题意:1..9个数,从中选择k个,和为n,要求输出所有满足题意的集合。

思路:枚举子集,根据sum和集合元素个数剪枝即可。

 

作者: CrazyKK

ex-ACMer@hust,researcher@sensetime

说点什么

您将是第一位评论人!

提醒
wpDiscuz