Leetcode Permutation Sequence

Tags: ,

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 (ie, for n = 3):

  1. "123"
  2. "132"
  3. "213"
  4. "231"
  5. "312"
  6. "321"

Given n and k, return the kth permutation sequence.

Note: Given n will be between 1 and 9 inclusive.

Java solution:

 

Refernce:

https://leetcode.com/problems/permutation-sequence/

http://fisherlei.blogspot.com/2013/04/leetcode-permutation-sequence-solution.html