There is an interview problem. Given a string without duplicate characters, return all permutations of the string.
First Try The straightforward idea is using recursive algorithms. We enum all characters for the first position and concatate the permutations of the rest substring.
However, the speed is too slow when the string is a little logger, like “abcdefghi”.
So, we have to try the iterative solution.
There is an algorithm call “Next Permutation”.