mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 13:36:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个只包含小写字母的字符串 <code>s</code> ,你需要找到 <code>s</code> 中最多数目的非空子字符串,满足如下条件:</p>\n\n<ol>\n\t<li>这些字符串之间互不重叠,也就是说对于任意两个子字符串 <code>s[i..j]</code> 和 <code>s[k..l]</code> ,要么 <code>j < k</code> 要么 <code>i > l</code> 。</li>\n\t<li>如果一个子字符串包含字符 <code>char</code> ,那么 <code>s</code> 中所有 <code>char</code> 字符都应该在这个子字符串中。</li>\n</ol>\n\n<p>请你找到满足上述条件的最多子字符串数目。如果有多个解法有相同的子字符串数目,请返回这些子字符串总长度最小的一个解。可以证明最小总长度解是唯一的。</p>\n\n<p>请注意,你可以以 <strong>任意</strong> 顺序返回最优解的子字符串。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><strong>输入:</strong>s = "adefaddaccc"\n<strong>输出:</strong>["e","f","ccc"]\n<strong>解释:</strong>下面为所有满足第二个条件的子字符串:\n[\n "adefaddaccc"\n "adefadda",\n "ef",\n "e",\n "f",\n "ccc",\n]\n如果我们选择第一个字符串,那么我们无法再选择其他任何字符串,所以答案为 1 。如果我们选择 "adefadda" ,剩下子字符串中我们只可以选择 "ccc" ,它是唯一不重叠的子字符串,所以答案为 2 。同时我们可以发现,选择 "ef" 不是最优的,因为它可以被拆分成 2 个子字符串。所以最优解是选择 ["e","f","ccc"] ,答案为 3 。不存在别的相同数目子字符串解。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><strong>输入:</strong>s = "abbaccd"\n<strong>输出:</strong>["d","bb","cc"]\n<strong>解释:</strong>注意到解 ["d","abba","cc"] 答案也为 3 ,但它不是最优解,因为它的总长度更长。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= s.length <= 10^5</code></li>\n\t<li><code>s</code> 只包含小写英文字母。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 69,
|
||||
"likes": 70,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"2.7K\", \"totalSubmission\": \"8K\", \"totalAcceptedRaw\": 2703, \"totalSubmissionRaw\": 8016, \"acRate\": \"33.7%\"}",
|
||||
"stats": "{\"totalAccepted\": \"2.7K\", \"totalSubmission\": \"8.1K\", \"totalAcceptedRaw\": 2745, \"totalSubmissionRaw\": 8083, \"acRate\": \"34.0%\"}",
|
||||
"hints": [
|
||||
"Notice that it's impossible for any two valid substrings to overlap unless one is inside another.",
|
||||
"We can start by finding the starting and ending index for each character.",
|
||||
|
Reference in New Issue
Block a user