PythonCode.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:LeetCode 作者: yingcuhk 项目源码 文件源码
def getPermutation(self, n, k):
        """
        :type n: int
        :type k: int
        :rtype: str
        """
        k = k-1
        L = [l for l in range(1,n+1)]
        S = ""
        for l in xrange(n):
            base = factorial(n-l-1)
            ind = k // base
            k = k % base
            S += str(L[ind])
            L.remove(L[ind])



        return S
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号