Given a collection of candidate numbers that may contain duplicates, and a target, find all unique combinations where the chosen numbers sum to the target; each number may be used at most once per combination.
candidates = [10,1,2,7,6,1,5], target = 8[[1,1,6],[1,2,5],[1,7],[2,6]]Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →Explore a decision one choice at a time, undo it if it doesn't lead anywhere, and try the next option. It's a systematic way to generate every valid combination, permutation, or arrangement.
Read the full Backtracking guide →
Original problem on LeetCode ↗