Combination Sum III
Find all valid combinations of k distinct numbers chosen from 1 through 9 that sum to n. Each number may be used at most once and each combination must be unique.
Open official problem prompt ↗List every unordered group of exactly k different digits (1 through 9) whose values add up to n.
Like choosing k different coins from a tray holding one each of coins 1..9 so their total equals n; once you pass a coin you cannot come back to it, keeping every group in increasing order.
- Input
- k = 3, n = 7
- Output
- [[1,2,4]]
- Why
- 1 + 2 + 4 = 7 uses exactly 3 distinct digits from 1..9; no other size-3 subset of distinct digits sums to 7.
2 <= k <= 91 <= n <= 60Each number 1..9 used at most onceAll combinations must be unique