216 Combination Sum III
216. Combination Sum III
1. Question
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:
2. Implementation
(1) Backtracking
3. Time & Space Complexity
Backtracking: 时间复杂度O(n^k), 根据组合公式得到,空间复杂度O(n^k)
Last updated