60. Permutation Sequence
Hard — Math, Factorial Number System
n:
1
2
3
4
5
6
7
8
9
k:
(max 24)
Apply
Play
Pause
Step
Reset
Speed:
Slow
Normal
Fast
Very Fast
Press "Play" or "Step" to walk through the factorial decomposition.
Step
0 / 0
Position i
--
Remaining k
--
Result
--
Index q (target)
Picked digit
Remaining
Algorithm Complexity
Generate All
O(n · n!)
Time / Space: O(n · n!) / O(n)
Iterate next-perm
O(k · n)
Time / Space: O(k · n) / O(n)
Factorial Decomposition
O(n²)
Time / Space: O(n²) / O(n)