Skip to content

Latest commit

 

History

History
95 lines (38 loc) · 1.26 KB

File metadata and controls

95 lines (38 loc) · 1.26 KB

Description

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:

    <li><code>&quot;123&quot;</code></li>
    
    <li><code>&quot;132&quot;</code></li>
    
    <li><code>&quot;213&quot;</code></li>
    
    <li><code>&quot;231&quot;</code></li>
    
    <li><code>&quot;312&quot;</code></li>
    
    <li><code>&quot;321&quot;</code></li>
    

Given n and k, return the kth permutation sequence.

Note:

    <li>Given <em>n</em> will be between 1 and 9 inclusive.</li>
    
    <li>Given&nbsp;<em>k</em>&nbsp;will be between 1 and <em>n</em>! inclusive.</li>
    

Example 1:

Input: n = 3, k = 3

Output: "213"

Example 2:

Input: n = 4, k = 9

Output: "2314"

Solutions

Python3

Java

...