Find All Permutations
Advanced
Let's help our little robot friend in calculating all the possible ways to rearrange a set of letters!
Your task is to write a function that returns all permutations of a given string. A permutation of a string is another string that contains the same characters, only the order of characters can be different.
For example, the string "abc" has the following permutations:
- "abc"
- "acb"
- "bac"
- "bca"
- "cab"
- "cba"
Example
find_all_permutations("abc")
returns:
["abc", "acb", "bac", "bca", "cab", "cba"]
Note
- The function should return the permutations sorted in lexicographical order.
- You can assume that all characters in the input string are unique.
Inputs
Arg 1:
"abc"Expected Output
["abc", "acb", "bac", "bca", "cab", "cba"]Actual Output