(self, candidates: List[int], target: int)
| 4 | |
| 5 | class Solution: |
| 6 | def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: |
| 7 | result = [] |
| 8 | |
| 9 | def backtrack(temp: List[int], remain: int, start: int): |
| 10 | if remain < 0: |
| 11 | return |
| 12 | if remain == 0: |
| 13 | result.append(temp[:]) |
| 14 | return |
| 15 | |
| 16 | for i in range(start, len(candidates)): |
| 17 | temp.append(candidates[i]) |
| 18 | backtrack(temp, remain - candidates[i], i) |
| 19 | temp.pop() |
| 20 | |
| 21 | backtrack([], target, 0) |
| 22 | return result |
nothing calls this directly
no test coverage detected