function combinationSum(candidates, target):
result = []
backtrack(0, [], 0, result, candidates, target)
return result
function backtrack(start, current, currentSum, result, candidates, target):
if currentSum == target:
result.append(copy of current)
return
if currentSum > target:
return # prune this branch
for i from start to length(candidates):
current.append(candidates[i])
backtrack(i, current, currentSum + candidates[i], result, candidates, target)
current.pop() # backtrack