216. Combination Sum III
Practice Combination Sum III for free on NudgeCode: Medium, Backtracking pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Pick k different numbers from 1 to 9 so that they add up to n. Return every such combination; each number is used at most once per combination, and no combination may appear twice. The combinations, and the numbers inside each, can be in any order. Return [] if there is none.
Example
k = 3, n = 9 -> [[1,2,6],[1,3,5],[2,3,4]]
Constraints
- 2 <= k <= 9
- 1 <= n <= 60