bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
HardMath & GeometryLC 60

Permutation Sequence

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:

  1. "123 "
  2. "132 "
  3. "213 "
  4. "231 "
  5. "312 "
  6. "321 " Given n and k, return the kth permutation sequence.
Asked at 7 companies
AmazonAppleFacebook
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode