Practice Permutation Sequence
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Consider all permutations of the numbers 1 through n, ordered lexicographically. Return the permutation in position k, counting the first permutation as position 1. For n = 3, the order is 123, 132, 213, 231, 312, 321.
Source: Permutation Sequence on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 3, k = 3
Output
"213"
# Example 2
Input
n = 4, k = 9
Output
"2314"
# Example 3
Input
n = 3, k = 1
Output
"123"
Constraints
1 <= n <= 9
1 <= k <= n!
Related LeetCode Problems
Practice more problems similar to Permutation Sequence.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.