Hardrecursionstringsbacktracking
All Permutations
Time limit 2 s · Memory 64 MBAcceptance: 100.0%Solved by: 1
Statement
You are given a string of distinct lowercase Latin letters. Print every permutation of its letters in lexicographic (alphabetical) order, one per line.
Examples
Example 1
Input
ab
Output
ab ba
Example 2
Input
abc
Output
abc acb bac bca cab cba
Constraints
- String length is between 1 and 6