index.ts875 chars33 lines
The getPermutations
function takes a set as an argument and utilizes a recursive backtracking algorithm to calculate all possible permutations. To ensure that the resulting permutations are distinct, each permutation is also stringified and checked for duplicates before adding it to the final list of results.
gistlibby LogSnag