60 Permutation Sequence

1. Question

The set[1,2,3,…,n]contains a total ofn! unique permutations.

By listing and labeling all of the permutations in order, We get the following sequence (ie, forn= 3):

  1. "123"

  2. "132"

  3. "213"

  4. "231"

  5. "312"

  6. "321"

Given n and k, return the kth permutation sequence.

2. Implementation

(1) Math

思路 https://leetcode.com/problems/permutation-sequence/discuss/22507/%22Explain-like-I'm-five%22-Java-Solution-in-O(n\)

3. Time & Space Complexity

Math: 时间复杂度O(n), 空间复杂度O(n)

Last updated

Was this helpful?