Kth Permutation

给定 n k,求123..n组成的排列中的第k个排列

By listing and labeling all of the permutations in order,

We get the following sequence (ie, for n = 3):

  1. "123"

  2. "132"

  3. "213"

  4. "231"

  5. "312"

  6. "321"

Given n and k, return the kth permutation sequence.

Note: Given n will be between 1 and 9 inclusive.

Example

Example 1:

Input:
 n = 3, k = 3

Output:
 "213"

Example 2:

Note

To be revisited...

Code

Last updated