If you generate permutations in lexicographic order one at a time, you only need
to change suffix of the previous permutation which should be faster than O(n * n!)
This paper by Rainer Kemp has investigates the complexity:
https://link.springer.com/article/10.1007/s002360050114