1Pass a mutable "current path" list and a "results" list through the recursion — append to path on choice, pop on undo.
2Sort the input first to make deduplication easier — skip duplicate elements at the same recursion level.
3Prune as early as possible: check constraints before recursing, not after.
4Use a boolean visited[] array for permutations to avoid reusing elements; use a start index for combinations to avoid duplicates.