60. Permutation Sequence Hard
1/**
2 * [60] Permutation Sequence
3 *
4 * The set [1, 2, 3, ..., n] contains a total of n! unique permutations.
5 * By listing and labeling all of the permutations in order, we get the following sequence for n = 3:
6 * <ol>
7 * "123"
8 * "132"
9 * "213"
10 * "231"
11 * "312"
12 * "321"
13 * </ol>
14 * Given n and k, return the k^th permutation sequence.
15 *
16 * Example 1:
17 * Input: n = 3, k = 3
18 * Output: "213"
19 * Example 2:
20 * Input: n = 4, k = 9
21 * Output: "2314"
22 * Example 3:
23 * Input: n = 3, k = 1
24 * Output: "123"
25 *
26 * Constraints:
27 *
28 * 1 <= n <= 9
29 * 1 <= k <= n!
30 *
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/permutation-sequence/
35// discuss: https://leetcode.com/problems/permutation-sequence/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40 pub fn get_permutation(n: i32, k: i32) -> String {
41 String::new()
42 }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn test_60() {
53 }
54}
55
Back
© 2025 bowen.ge All Rights Reserved.