class Solution:
def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]:
n = len(candidates)
results = []
candidates.sort()
def dfs(path, t, start):
if t < 0:
return
if t == 0:
results.append(path[:])
seen = set()
for i in range(start, n):
if candidates[i] in seen:
continue
seen.add(candidates[i])
path.append(candidates[i])
dfs(path, t - candidates[i], i + 1)
path.pop()
dfs([], target, 0)
return results