LeetCode: K-th arrangement [60]

LeetCode: K-th arrangement [60]

Title Description

Given set [1,2,3, ..., n], a total of all the elements n! Permutations.

Arranged in order of size lists all cases, and 11 markers, when when n 3 =, all arranged as follows:

"123"
"132"
"213"
"231"
"312"
"321"

A given n and k, returns the k-th order.

Description:

Given n ranges [1, 9].
K is given range [1, n!].

Example 1:

Input: n = 3, k = 3
Output: "213"

Example 2:

Input: n = 4, k = 9
Output: "2314"

Topic analysis

 

Java solution to a problem

 

Guess you like

Origin www.cnblogs.com/MrSaver/p/11610167.html
Recommended