Grokking Google Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Mohammed Dh Abbas
My simple solution

Mohammed Dh Abbas

Sep 15, 2024

class Solution: def combinationSum(self, candidates, target): def backtrack(result, index, path, add): if add > target: return if add == target: result.append(path[:]) for i in range(index, len(candidates)): path.append(candidates[i]) add += candidates[i] backtrack(result, i, path, add) add -= candidates[i] path.pop() result = [] backtrack(result, 0, [], 0) return result

0

0

Comments
Comments

On this page