You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 res
The text was updated successfully, but these errors were encountered:
I came across a Python solution for the Combination Sum problem that was missing. The code below works for that purpose.
The text was updated successfully, but these errors were encountered: