1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-22 21:46:46 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个数组 <code>target</code> ,包含若干 <strong>互不相同</strong> 的整数,以及另一个整数数组 <code>arr</code> <code>arr</code> <strong>可能</strong> 包含重复元素。</p>\n\n<p>每一次操作中,你可以在 <code>arr</code> 的任意位置插入任一整数。比方说,如果 <code>arr = [1,4,1,2]</code> ,那么你可以在中间添加 <code>3</code> 得到 <code>[1,4,<strong>3</strong>,1,2]</code> 。你可以在数组最开始或最后面添加整数。</p>\n\n<p>请你返回 <strong>最少</strong> 操作次数,使得<em> </em><code>target</code><em> </em>成为 <code>arr</code> 的一个子序列。</p>\n\n<p>一个数组的 <strong>子序列</strong> 指的是删除原数组的某些元素(可能一个元素都不删除),同时不改变其余元素的相对顺序得到的数组。比方说,<code>[2,7,4]</code> 是 <code>[4,<strong>2</strong>,3,<strong>7</strong>,2,1,<strong>4</strong>]</code> 的子序列(加粗元素),但 <code>[2,4,2]</code> 不是子序列。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><b>输入:</b>target = [5,1,3], <code>arr</code> = [9,4,2,3,4]\n<b>输出:</b>2\n<b>解释:</b>你可以添加 5 和 1 ,使得 arr 变为 [<strong>5</strong>,9,4,<strong>1</strong>,2,3,4] target 为 arr 的子序列。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><b>输入:</b>target = [6,4,8,1,3,2], <code>arr</code> = [4,7,6,2,3,8,6,1]\n<b>输出:</b>3\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= target.length, arr.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= target[i], arr[i] &lt;= 10<sup>9</sup></code></li>\n\t<li><code>target</code> 不包含任何重复元素。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 171,
"likes": 174,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"16.5K\", \"totalSubmission\": \"33.4K\", \"totalAcceptedRaw\": 16531, \"totalSubmissionRaw\": 33409, \"acRate\": \"49.5%\"}",
"stats": "{\"totalAccepted\": \"16.7K\", \"totalSubmission\": \"33.7K\", \"totalAcceptedRaw\": 16679, \"totalSubmissionRaw\": 33711, \"acRate\": \"49.5%\"}",
"hints": [
"The problem can be reduced to computing Longest Common Subsequence between both arrays.",
"Since one of the arrays has distinct elements, we can consider that these elements describe an arrangement of numbers, and we can replace each element in the other array with the index it appeared at in the first array.",