The challenge Given a lowercase word, return every permutation of its letters in alphabetical order. Do not use built-in permutation libraries. Examples: permutations('the'); // → ['eht', 'eth', 'het', 'hte', 'teh', 'the'] permutations('a'); // → ['a'] This is a Codewars classic in the JavaScript track. The two stumbling blocks are generating the permutations from scratch and producing them alphabetically. Solution 1: recursion + dedup + sort The most direct version. Recurse to build, Set to dedupe, sort to order:
No comments yet. Log in to reply on the Fediverse. Comments will appear here.