本文主要是介绍60. Permutation Sequence(Leetcode每日一题-2020.09.05),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Problem
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 for n = 3:
“123”
“132”
“213”
“231”
“312”
“321”
Given n and k, return the kth permutation sequence.
Note:
- Given n will be between 1 and 9 inclusive.
- Given k will be between 1 and n! inclusive.
Example1
Input: n = 3, k = 3
Output: “213”
Example2
Input: n = 4, k = 9
Output: “2314”
Solution
这篇关于60. Permutation Sequence(Leetcode每日一题-2020.09.05)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!