###### leetcode 60:Permutation Sequence
1. public class Solution {
2.     public String getPermutation(int n, int k) {
3.         StringBuilder sb = new StringBuilder();
4.         for(int i=1; i<=n; i++) {sb.append(i);}
5.
6.         StringBuilder ret = new StringBuilder();
7.
8.         int[] factor = new int[n];
9.         factor[0] = 1;
10.         for(int i=1; i<n; i++) { factor[i] = factor[i-1] * i;}
11.
12.         k--;    // note factorial number begins from 0 instead of 1
13.         for(int i=n-1; i>0; i--){
14.             int code = k/factor[i];
15.             k = k%factor[i];
16.
17.             ret.append(sb.charAt(code));
18.             sb.deleteCharAt(code);
19.         }
20.
21.         return ret.toString();
22.     }
23. }

5/3! = 0 余5
5/2! = 2 余1
1/1! = 1 余0
0 (lehmer code最后一位总为0)

#### LeetCode-60-Permutation Sequence(找规律)-Medium

2016-03-04 09:07:30

#### LeetCode(60): Permutation Sequence (C++)

2015-12-01 10:44:16

#### LeetCode 60 Permutation Sequence （Python实现及详解）

2017-08-01 16:23:00

#### (Java)LeetCode-60. Permutation Sequence

2016-10-05 23:52:58

#### 【leetcode】【60】Permutation Sequence

2016-03-02 09:21:16

#### Leetcode #60. Permutation Sequence 排列组合序列 解题报告

2016-04-30 23:06:32

#### LeetCode 60. Permutation Sequence（排列序列）

2016-05-21 09:05:38

#### Leetcode: Permutation Sequence

2013-10-17 17:56:05

#### [C++]LeetCode: 114 Permutation Sequence（返回第k个阶乘序列——寻找数学规律）

2015-01-20 20:48:30

#### Permutation Sequence -- LeetCode

2014-03-25 06:41:17

## 不良信息举报

leetcode 60:Permutation Sequence