- Notifications
You must be signed in to change notification settings - Fork204
Open
Description
I came across a Python solution for the Combination Sum problem that was missing. The code below works for that purpose.
res, sol = [], []def backtrack(): if sum(sol) == target: res.append(sol[:]) return if sum(sol) > target: return for i in candidates: if len(sol) > 0 and i < sol[-1]: continue sol.append(i) backtrack() sol.pop()backtrack()return resMetadata
Metadata
Assignees
Labels
No labels