1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/排列序列 [permutation-sequence].html
2022-03-29 12:43:11 +08:00

47 lines
1007 B
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给出集合 <code>[1,2,3,...,n]</code>,其所有元素共有 <code>n!</code> 种排列。</p>
<p>按大小顺序列出所有排列情况,并一一标记,当 <code>n = 3</code> 时, 所有排列如下:</p>
<ol>
<li><code>"123"</code></li>
<li><code>"132"</code></li>
<li><code>"213"</code></li>
<li><code>"231"</code></li>
<li><code>"312"</code></li>
<li><code>"321"</code></li>
</ol>
<p>给定 <code>n</code> 和 <code>k</code>,返回第 <code>k</code> 个排列。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 3, k = 3
<strong>输出:</strong>"213"
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>n = 4, k = 9
<strong>输出:</strong>"2314"
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>n = 3, k = 1
<strong>输出:</strong>"123"
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= n <= 9</code></li>
<li><code>1 <= k <= n!</code></li>
</ul>