Practice: Combination Sum
Problem: https://leetcode.com/problems/combination-sum/
Recognition reminder: you are asked for every combination of candidates that sums to a target, and any candidate may be reused. “Find all combinations that satisfy X” is the backtracking cue. Two things make this problem its own lesson: the prune (a running remainder that, once negative, kills the branch) and reuse (a candidate can appear more than once in a combination).
Before you start (the five-beat rhythm)
- Your Pattern Card for this week is already written.
- Name the pattern aloud and write your approach as a plain-English comment before any code.
- Struggle floor: 25 minutes unaided. No hints, no AI, no Discuss tab.
- If stuck past the floor, ask the tutor for a hint. Six rungs, one per ask.
- Debrief in your commit message before moving to the next problem.
Your target
Fill these in yourself before you look at anyone else’s solution:
Target time complexity: ____
Target space complexity: ____
Think about two separate questions when you reason about the cost: what lets a candidate be used more than once in a single combination, and what stops a branch from running forever once the remaining target has gone past zero. Both have a small, specific answer in the structure of your recursion; find them before you write code.
Where your code goes
Write your solution in your own work repo (see getting-started.md), not in this folder. This folder ships only the problem spec and a provided-example test (tests/test_provided.py) so you can check the given cases locally before you submit to LeetCode’s judge. The judge is the oracle; the tutor will not confirm your answer by reading it.
Note on the test: the combinations may be returned in any order, and the order of numbers inside each combination does not matter either, so the provided test normalizes both sides (it sorts within each combination, then sorts the list of combinations) before comparing. A combination may contain the same number several times, and that is expected; sorting preserves those repeats.
Debrief (paste into your commit message)
1. What pattern did this turn out to be?
2. What was the trigger phrase or input shape that should have made me reach for it?
3. What was the time and space complexity, and what would dominate at scale?
4. What edge case would have broken my first attempt?
5. What would I do differently in three days when I see this cold?