1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 14:12:17 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-03-29 16:56:27 +08:00
parent e730aa6794
commit ad15da05aa
2517 changed files with 7358 additions and 7332 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个只包含小写英文字母的字符串&nbsp;<code>s</code>&nbsp;。</p>\n\n<p>每一次 <strong>操作</strong>&nbsp;,你可以选择 <code>s</code>&nbsp;中两个 <strong>相邻</strong>&nbsp;的字符,并将它们交换。</p>\n\n<p>请你返回将 <code>s</code>&nbsp;变成回文串的 <strong>最少操作次数</strong>&nbsp;。</p>\n\n<p><strong>注意</strong>&nbsp;,输入数据会确保&nbsp;<code>s</code>&nbsp;一定能变成一个回文串。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><b>输入:</b>s = \"aabb\"\n<b>输出:</b>2\n<strong>解释:</strong>\n我们可以将 s 变成 2 个回文串,\"abba\" 和 \"baab\" 。\n- 我们可以通过 2 次操作得到 \"abba\" \"a<em><strong>ab</strong></em>b\" -&gt; \"ab<em><strong>ab</strong></em>\" -&gt; \"abba\" 。\n- 我们可以通过 2 次操作得到 \"baab\" \"a<em><strong>ab</strong></em>b\" -&gt; \"<em><strong>ab</strong></em>ab\" -&gt; \"baab\" 。\n因此得到回文串的最少总操作次数为 2 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><b>输入:</b>s = \"letelt\"\n<b>输出:</b>2\n<strong>解释:</strong>\n通过 2 次操作从 s 能得到回文串 \"lettel\" 。\n其中一种方法是\"lete<em><strong>lt</strong></em>\" -&gt; \"let<em><strong>et</strong></em>l\" -&gt; \"lettel\" 。\n其他回文串比方说 \"tleelt\" 也可以通过 2 次操作得到。\n可以证明少于 2 次操作,无法得到回文串。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= s.length &lt;= 2000</code></li>\n\t<li><code>s</code>&nbsp;只包含小写英文字母。</li>\n\t<li><code>s</code>&nbsp;可以通过有限次操作得到一个回文串。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 25,
"likes": 26,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"2.1K\", \"totalSubmission\": \"4.6K\", \"totalAcceptedRaw\": 2145, \"totalSubmissionRaw\": 4603, \"acRate\": \"46.6%\"}",
"stats": "{\"totalAccepted\": \"2.2K\", \"totalSubmission\": \"4.6K\", \"totalAcceptedRaw\": 2154, \"totalSubmissionRaw\": 4616, \"acRate\": \"46.7%\"}",
"hints": [
"Consider a greedy strategy.",
"Lets start by making the leftmost and rightmost characters match with some number of swaps.",