mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-02 14:12:17 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个只包含小写英文字母的字符串 <code>s</code> 。</p>\n\n<p>每一次 <strong>操作</strong> ,你可以选择 <code>s</code> 中两个 <strong>相邻</strong> 的字符,并将它们交换。</p>\n\n<p>请你返回将 <code>s</code> 变成回文串的 <strong>最少操作次数</strong> 。</p>\n\n<p><strong>注意</strong> ,输入数据会确保 <code>s</code> 一定能变成一个回文串。</p>\n\n<p> </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\" -> \"ab<em><strong>ab</strong></em>\" -> \"abba\" 。\n- 我们可以通过 2 次操作得到 \"baab\" :\"a<em><strong>ab</strong></em>b\" -> \"<em><strong>ab</strong></em>ab\" -> \"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>\" -> \"let<em><strong>et</strong></em>l\" -> \"lettel\" 。\n其他回文串比方说 \"tleelt\" 也可以通过 2 次操作得到。\n可以证明少于 2 次操作,无法得到回文串。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= s.length <= 2000</code></li>\n\t<li><code>s</code> 只包含小写英文字母。</li>\n\t<li><code>s</code> 可以通过有限次操作得到一个回文串。</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.",
|
||||
"Let’s start by making the leftmost and rightmost characters match with some number of swaps.",
|
||||
|
Reference in New Issue
Block a user