Skip to content

Commit a8516a7

Browse files
authored
Update permutation-sequence.py
1 parent f9b9cef commit a8516a7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Python/permutation-sequence.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@
2020
import math
2121

2222
# Cantor ordering solution
23-
class Solution:
24-
# @return a string
23+
class Solution(object):
2524
def getPermutation(self, n, k):
25+
"""
26+
:type n: int
27+
:type k: int
28+
:rtype: str
29+
"""
2630
seq, k, fact = "", k - 1, math.factorial(n - 1)
2731
perm = [i for i in xrange(1, n + 1)]
2832
for i in reversed(xrange(n)):
@@ -33,6 +37,7 @@ def getPermutation(self, n, k):
3337
k %= fact
3438
fact /= i
3539
return seq
40+
3641

3742
if __name__ == "__main__":
3843
print Solution().getPermutation(3, 2)

0 commit comments

Comments
 (0)