[置顶] 求第k个排列组合(Permutation Sequence)

60. Permutation Sequence

My Submissions
Question Editorial Solution
Total Accepted: 52210  Total Submissions: 208943  Difficulty: Medium

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

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.

Subscribe to see which companies asked this question

Show Tags
Show Similar Problems







下面这是我分析的示意图:

[置顶] 求第k个排列组合(Permutation Sequence)_第1张图片

下面是代码实现:

[置顶] 求第k个排列组合(Permutation Sequence)_第2张图片

你可能感兴趣的:(算法)