-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/combination-target-sum
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
This incorrect solution exposes your implementation
class Solution:
def combinationSum(self, nums: List[int], target: int) -> List[List[int]]:
nums.sort()
result = set()
def dfs(i, new_target, cur_arr):
print(cur_arr)
nonlocal result
if i > len(nums):
return
if new_target < 0:
return
if new_target == 0:
if tuple(cur_arr) not in result:
result.add(tuple(cur_arr.copy()))
return
for j in range(i, len(nums)):
cur_arr.append(nums[j])
dfs(j, new_target - nums[j], cur_arr)
cur_arr.pop()
return
dfs(0,target,[])
return list(result)
More specifically:
Expected output:
===USE_THIS_LINE_TO_SEPARATE_USER_LOGS_AND_TEST_CASE_OUTPUT_394w8389wry89areisJAHSDBHJBdsjnkzbdcifbscidfbasekhfgiJHBG===
Metadata
Metadata
Assignees
Labels
No labels