216 Combination Sum III
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
Example 1:
Input: k= 3,n= 7
Output:
Example 2:
Input:k= 3,n= 9
Output:
(1) Backtracking
Backtracking: 时间复杂度O(n^k), 根据组合公式得到,空间复杂度O(n^k)