Each number can be used at most once; avoid duplicate combinations by sorting and skipping duplicates per depth.
Sort candidates. Backtrack with (start, remaining):
i from start.candidates[i], recurse with i+1 (no reuse), then undo.
Stop early when candidate > remaining.Sorting ensures duplicates are adjacent; depth-level skipping prevents generating the same combination in different ways.
Each number can be used at most once; avoid duplicate combinations by sorting and skipping duplicates per depth.
Sort candidates. Backtrack with (start, remaining):
i from start.candidates[i], recurse with i+1 (no reuse), then undo.
Stop early when candidate > remaining.Sorting ensures duplicates are adjacent; depth-level skipping prevents generating the same combination in different ways.