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>给你一个字符串&nbsp;<code>s</code>,请你对&nbsp;<code>s</code>&nbsp;的子串进行检测。</p>\n\n<p>每次检测,待检子串都可以表示为&nbsp;<code>queries[i] = [left, right, k]</code>。我们可以 <strong>重新排列</strong> 子串&nbsp;<code>s[left], ..., s[right]</code>,并从中选择 <strong>最多</strong> <code>k</code>&nbsp;项替换成任何小写英文字母。&nbsp;</p>\n\n<p>如果在上述检测过程中,子串可以变成回文形式的字符串,那么检测结果为&nbsp;<code>true</code>,否则结果为&nbsp;<code>false</code>。</p>\n\n<p>返回答案数组&nbsp;<code>answer[]</code>,其中&nbsp;<code>answer[i]</code>&nbsp;是第&nbsp;<code>i</code>&nbsp;个待检子串&nbsp;<code>queries[i]</code>&nbsp;的检测结果。</p>\n\n<p>注意:在替换时,子串中的每个字母都必须作为 <strong>独立的</strong> 项进行计数,也就是说,如果&nbsp;<code>s[left..right] = &quot;aaa&quot;</code>&nbsp;且&nbsp;<code>k = 2</code>,我们只能替换其中的两个字母。(另外,任何检测都不会修改原始字符串 <code>s</code>,可以认为每次检测都是独立的)</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例:</strong></p>\n\n<pre><strong>输入:</strong>s = &quot;abcda&quot;, queries = [[3,3,0],[1,2,0],[0,3,1],[0,3,2],[0,4,1]]\n<strong>输出:</strong>[true,false,false,true,true]\n<strong>解释:</strong>\nqueries[0] : 子串 = &quot;d&quot;,回文。\nqueries[1] :&nbsp;子串 = &quot;bc&quot;,不是回文。\nqueries[2] :&nbsp;子串 = &quot;abcd&quot;,只替换 1 个字符是变不成回文串的。\nqueries[3] :&nbsp;子串 = &quot;abcd&quot;,可以变成回文的 &quot;abba&quot;。 也可以变成 &quot;baab&quot;,先重新排序变成 &quot;bacd&quot;,然后把 &quot;cd&quot; 替换为 &quot;ab&quot;。\nqueries[4] :&nbsp;子串 = &quot;abcda&quot;,可以变成回文的 &quot;abcba&quot;。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= s.length,&nbsp;queries.length&nbsp;&lt;= 10^5</code></li>\n\t<li><code>0 &lt;= queries[i][0] &lt;= queries[i][1] &lt;&nbsp;s.length</code></li>\n\t<li><code>0 &lt;= queries[i][2] &lt;= s.length</code></li>\n\t<li><code>s</code> 中只有小写英文字母</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 58,
"likes": 60,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"6.8K\", \"totalSubmission\": \"24.6K\", \"totalAcceptedRaw\": 6763, \"totalSubmissionRaw\": 24578, \"acRate\": \"27.5%\"}",
"stats": "{\"totalAccepted\": \"6.9K\", \"totalSubmission\": \"24.9K\", \"totalAcceptedRaw\": 6889, \"totalSubmissionRaw\": 24885, \"acRate\": \"27.7%\"}",
"hints": [
"Since we can rearrange the substring, all we care about is the frequency of each character in that substring.",
"How to find the character frequencies efficiently ?",