← Back to challenges

Generate All String Character Permutations

PythonHardalgorithmsinterviewloopsstrings

Instructions

Create a function to generate all string character permutations.

Examples

permutations("AB") ➞ "AB BA"

permutations("CD") ➞ "CD DC"

permutations("EF") ➞ "EF FE"

permutations("NOT") ➞ "NOT NTO ONT OTN TNO TON"

permutations("RAM") ➞ "AMR ARM MAR MRA RAM RMA"

permutations("YAW") ➞ "AWY AYW WAY WYA YAW YWA"

Notes

Sort your results in alphabetical order before returning them.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.