60. Permutation Sequence

Hard — Math, Factorial Number System

(max 24)
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)