Permutations Alphabetically (Java) 0 ▲ Andrew Odendaal 188 days ago · Tech · hide · Fediverse post The challenge Given a word (a string of lowercase letters), return all its permutations in alphabetical order. Do not use built-in permutation functions. Examples: permutations("the"); // → [eht, eth, het, hte, teh, the] permutations("a"); // → [a] This puzzle is asked on Codewars and HackerRank Java tracks. Two parts trip people up: generating the permutations from scratch, and ordering them alphabetically. Solution 1: recursive, no built-ins The classic recursive approach. Each call removes one character, recurses on the rest, then prepends the removed character to every sub-result: Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town