Digit combinations with sum
Your task
Find all distinct combinations of exactly k different digits from 1 to 9 that sum to n. Each digit may be used at most once and combinations are unordered. Return the list of combinations, each as an ascending list of digits, with the overall list sorted ascending. 1 <= k <= 9 and 1 <= n <= 60.
Examples
combination_sum_iii(k: int, n: int) -> list[list[int]]Example 1
Input
combination_sum_iii(3, 7)Output
[[1, 2, 4]]