LeetCode刷题(35)--Permutation Sequence
来源:互联网 发布:berkeley db java 编辑:程序博客网 时间:2024/05/17 08:41
对于第一个数字,剩余共有(n-1)!中排列,因此第一个数字为k/(n-1)!,之后的数字依次类推
import mathclass Solution(object): def getPermutation(self, n, k): """ :type n: int :type k: int :rtype: str """ numbers = range(1, n+1) res = '' k -= 1 while n > 0: n -= 1 num, k = divmod(k, math.factorial(n)) res += str(numbers[num]) numbers.remove(numbers[num]) return res
阅读全文
0 0
- LeetCode刷题(35)--Permutation Sequence
- LeetCode(60) Permutation Sequence
- LeetCode OJ 之 Permutation Sequence (排列组合)
- LeetCode 60. Permutation Sequence(排列序列)
- LeetCode进阶之路(Permutation Sequence)
- leetcode:数学:Permutation Sequence(060)
- LeetCode: Permutation Sequence
- LeetCode Permutation Sequence
- [Leetcode] Permutation Sequence
- [LeetCode] Permutation Sequence
- leetcode 74: Permutation Sequence
- leetcode Permutation Sequence
- [leetcode] Permutation Sequence
- [LeetCode]Permutation Sequence
- LeetCode:Permutation Sequence
- LeetCode-Permutation SequencePermutation Sequence
- [leetcode] Permutation Sequence
- LeetCode - Permutation Sequence
- c语言:判断一个年份是不是闰年和鸡兔同笼问题
- React DOM click focus textbox
- 用python3 opencv3 实现相机学生证的实时跟踪
- svn 批量移除版本库
- linux学习
- LeetCode刷题(35)--Permutation Sequence
- vba基础打卡2
- Python数据挖掘建模 chapter_7 关联规则
- 外媒:BAT齐发力缩小与中美AI差距
- 东芝将退出电脑等业务纳入考虑 以避免摘牌退市
- 苹果称霸三季度美智能手机市场 三星缩小差距
- Linux基础复习1
- 计算机等级考试--三级网络技术2
- web audio api 振荡器(Oscillation)