Code Room
CodingMediumcod-g118
Subject CombinatoricsLevel Mid–Senior~20 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Implement
combination_sum_iii(k: int, n: int) → list[list[int]]
Examples
in[3,7]out[[1,2,4]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.