-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
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.
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
my code fails for this testcase on leetcode but works here, I guess this testcase isnt on neetcode?
my code is this
class Solution:
def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]:
ans = []
ans_map = []
def helper(i, acc, arr):
if acc == target:
curr_map = Counter(arr)
print("curr map", curr_map)
if curr_map not in ans_map:
ans_map.append(curr_map)
ans.append(arr.copy())
return
if i >= len(candidates) or acc > target:
return
arr.append(candidates[i])
helper(i+1, acc + candidates[i], arr)
arr.pop()
helper(i+1, acc, arr)
helper(0, 0, [])
return ansReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels