Bug Report for https://neetcode.io/problems/combination-target-sum-ii
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Using the example solution returns "Output Limit Reached":
class Solution:
def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]:
res = []
candidates.sort()
def dfs(i, cur, total):
if total == target:
res.append(cur.copy())
return
if total > target or i == len(candidates):
return
cur.append(candidates[i])
dfs(i + 1, cur, total + candidates[i])
cur.pop()
while i + 1 < len(candidates) and candidates[i] == candidates[i+1]:
i += 1
dfs(i + 1, cur, total)
dfs(0, [], 0)
return res
Bug Report for https://neetcode.io/problems/combination-target-sum-ii
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Using the example solution returns "Output Limit Reached":
class Solution:
def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]:
res = []
candidates.sort()