1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 00:11:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

移除零宽空格

This commit is contained in:
2025-05-25 15:06:02 +08:00
parent 59597532bc
commit 3070bed723
272 changed files with 1031 additions and 749 deletions

View File

@@ -7,7 +7,7 @@
"boundTopicId": 5941,
"title": "Kth Smallest Instructions",
"titleSlug": "kth-smallest-instructions",
"content": "<p>Bob is standing at cell <code>(0, 0)</code>, and he wants to reach <code>destination</code>: <code>(row, column)</code>. He can only travel <strong>right</strong> and <strong>down</strong>. You are going to help Bob by providing <strong>instructions</strong> for him to reach <code>destination</code>.</p>\n\n<p>The <strong>instructions</strong> are represented as a string, where each character is either:</p>\n\n<ul>\n\t<li><code>&#39;H&#39;</code>, meaning move horizontally (go <strong>right</strong>), or</li>\n\t<li><code>&#39;V&#39;</code>, meaning move vertically (go <strong>down</strong>).</li>\n</ul>\n\n<p>Multiple <strong>instructions</strong> will lead Bob to <code>destination</code>. For example, if <code>destination</code> is <code>(2, 3)</code>, both <code>&quot;HHHVV&quot;</code> and <code>&quot;HVHVH&quot;</code> are valid <strong>instructions</strong>.</p>\n\n<p>However, Bob is very picky. Bob has a lucky number <code>k</code>, and he wants the <code>k<sup>th</sup></code> <strong>lexicographically smallest instructions</strong> that will lead him to <code>destination</code>. <code>k</code> is <strong>1-indexed</strong>.</p>\n\n<p>Given an integer array <code>destination</code> and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>lexicographically smallest instructions</strong> that will take Bob to </em><code>destination</code>.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/12/ex1.png\" style=\"width: 300px; height: 229px;\" /></p>\n\n<pre>\n<strong>Input:</strong> destination = [2,3], k = 1\n<strong>Output:</strong> &quot;HHHVV&quot;\n<strong>Explanation:</strong> All the instructions that reach (2, 3) in lexicographic order are as follows:\n[&quot;HHHVV&quot;, &quot;HHVHV&quot;, &quot;HHVVH&quot;, &quot;HVHHV&quot;, &quot;HVHVH&quot;, &quot;HVVHH&quot;, &quot;VHHHV&quot;, &quot;VHHVH&quot;, &quot;VHVHH&quot;, &quot;VVHHH&quot;].\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/12/ex2.png\" style=\"width: 300px; height: 229px;\" /></strong></p>\n\n<pre>\n<strong>Input:</strong> destination = [2,3], k = 2\n<strong>Output:</strong> &quot;HHVHV&quot;\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/12/ex3.png\" style=\"width: 300px; height: 229px;\" /></strong></p>\n\n<pre>\n<strong>Input:</strong> destination = [2,3], k = 3\n<strong>Output:</strong> &quot;HHVVH&quot;\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>destination.length == 2</code></li>\n\t<li><code>1 &lt;= row, column &lt;= 15</code></li>\n\t<li><code>1 &lt;= k &lt;= nCr(row + column, row)</code>, where <code>nCr(a, b)</code> denotes <code>a</code> choose <code>b</code>.</li>\n</ul>\n",
"content": "<p>Bob is standing at cell <code>(0, 0)</code>, and he wants to reach <code>destination</code>: <code>(row, column)</code>. He can only travel <strong>right</strong> and <strong>down</strong>. You are going to help Bob by providing <strong>instructions</strong> for him to reach <code>destination</code>.</p>\n\n<p>The <strong>instructions</strong> are represented as a string, where each character is either:</p>\n\n<ul>\n\t<li><code>&#39;H&#39;</code>, meaning move horizontally (go <strong>right</strong>), or</li>\n\t<li><code>&#39;V&#39;</code>, meaning move vertically (go <strong>down</strong>).</li>\n</ul>\n\n<p>Multiple <strong>instructions</strong> will lead Bob to <code>destination</code>. For example, if <code>destination</code> is <code>(2, 3)</code>, both <code>&quot;HHHVV&quot;</code> and <code>&quot;HVHVH&quot;</code> are valid <strong>instructions</strong>.</p>\n\n<p>However, Bob is very picky. Bob has a lucky number <code>k</code>, and he wants the <code>k<sup>th</sup></code> <strong>lexicographically smallest instructions</strong> that will lead him to <code>destination</code>. <code>k</code> is <strong>1-indexed</strong>.</p>\n\n<p>Given an integer array <code>destination</code> and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>lexicographically smallest instructions</strong> that will take Bob to </em><code>destination</code>.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/12/ex1.png\" style=\"width: 300px; height: 229px;\" /></p>\n\n<pre>\n<strong>Input:</strong> destination = [2,3], k = 1\n<strong>Output:</strong> &quot;HHHVV&quot;\n<strong>Explanation:</strong> All the instructions that reach (2, 3) in lexicographic order are as follows:\n[&quot;HHHVV&quot;, &quot;HHVHV&quot;, &quot;HHVVH&quot;, &quot;HVHHV&quot;, &quot;HVHVH&quot;, &quot;HVVHH&quot;, &quot;VHHHV&quot;, &quot;VHHVH&quot;, &quot;VHVHH&quot;, &quot;VVHHH&quot;].\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/12/ex2.png\" style=\"width: 300px; height: 229px;\" /></strong></p>\n\n<pre>\n<strong>Input:</strong> destination = [2,3], k = 2\n<strong>Output:</strong> &quot;HHVHV&quot;\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/12/ex3.png\" style=\"width: 300px; height: 229px;\" /></strong></p>\n\n<pre>\n<strong>Input:</strong> destination = [2,3], k = 3\n<strong>Output:</strong> &quot;HHVVH&quot;\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>destination.length == 2</code></li>\n\t<li><code>1 &lt;= row, column &lt;= 15</code></li>\n\t<li><code>1 &lt;= k &lt;= nCr(row + column, row)</code>, where <code>nCr(a, b)</code> denotes <code>a</code> choose <code>b</code>.</li>\n</ul>\n",
"translatedTitle": "第 K 条最小指令",
"translatedContent": "<p>Bob 站在单元格 <code>(0, 0)</code> ,想要前往目的地 <code>destination</code> <code>(row, column)</code> 。他只能向 <strong>右</strong> 或向 <strong>下</strong> 走。你可以为 Bob 提供导航 <strong>指令</strong> 来帮助他到达目的地 <code>destination</code> 。</p>\n\n<p><strong>指令</strong> 用字符串表示,其中每个字符:</p>\n\n<ul>\n\t<li><code>'H'</code> ,意味着水平向右移动</li>\n\t<li><code>'V'</code> ,意味着竖直向下移动</li>\n</ul>\n\n<p>能够为 Bob 导航到目的地 <code>destination</code> 的指令可以有多种,例如,如果目的地 <code>destination</code> 是 <code>(2, 3)</code><code>\"HHHVV\"</code> 和 <code>\"HVHVH\"</code> 都是有效<strong> 指令</strong> 。</p>\n\n<ul>\n</ul>\n\n<p>然而Bob 很挑剔。因为他的幸运数字是 <code>k</code>,他想要遵循 <strong>按字典序排列后的第 <code>k</code> 条最小指令 </strong>的导航前往目的地 <code>destination</code> 。<code>k</code>  的编号 <strong>从 1 开始</strong> 。</p>\n\n<p>给你一个整数数组 <code>destination</code> 和一个整数 <code>k</code> ,请你返回可以为<em> </em>Bob<em> </em>提供前往目的地 <code>destination</code> 导航的<strong> 按字典序排列后的第 <code>k</code> 条最小指令 </strong>。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/11/01/ex1.png\" style=\"width: 300px;\" /></p>\n\n<pre>\n<strong>输入:</strong>destination = [2,3], k = 1\n<strong>输出:</strong>\"HHHVV\"\n<strong>解释:</strong>能前往 (2, 3) 的所有导航指令 <strong>按字典序排列后</strong> 如下所示:\n[\"HHHVV\", \"HHVHV\", \"HHVVH\", \"HVHHV\", \"HVHVH\", \"HVVHH\", \"VHHHV\", \"VHHVH\", \"VHVHH\", \"VVHHH\"].\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/11/01/ex2.png\" style=\"width: 300px; height: 229px;\" /></strong></p>\n\n<pre>\n<strong>输入:</strong>destination = [2,3], k = 2\n<strong>输出:</strong>\"HHVHV\"\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/11/01/ex3.png\" style=\"width: 300px; height: 229px;\" /></strong></p>\n\n<pre>\n<strong>输入:</strong>destination = [2,3], k = 3\n<strong>输出:</strong>\"HHVVH\"\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>destination.length == 2</code></li>\n\t<li><code>1 <= row, column <= 15</code></li>\n\t<li><code>1 <= k <= nCr(row + column, row)</code>,其中 <code>nCr(a, b)</code> 表示组合数,即从 <code>a</code> 个物品中选 <code>b</code> 个物品的不同方案数。</li>\n</ul>\n",
"isPaidOnly": false,