256. Combination Sum III
Determine all possible set of k numbers that can be added together to equal n while meeting the following requirements:
- There is only use of numerals 1 through 9.
- A single use is made of each number.
Return list of every feasible combination that is allowed. The combinations can be returned in any order, but the list cannot have the same combination twice.
Example 1:
Input : k = 3 , n = 7
Output : [ [1, 2, 4] ]
Explanation :
1 + 2 + 4 = 7
There are no other valid combinations.
Example 2:
Input : k = 3, n = 9
Output : [[1, 2, 6],[1, 3, 5],[2, 3, 4]]
Explanation :
1 + 2 + 6 = 9
1 + 3 + 5 = 9
2 + 3 + 4 = 9
There are no other valid combinations.
Now Your Turn!
Pick the correct output for the given inputInput : k = 3, n = 8
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 2 <= k <= 9
- 1 <= n <= 60