1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-12 10:51:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

存量题库数据更新

This commit is contained in:
2023-12-09 18:42:21 +08:00
parent a788808cd7
commit c198538f10
10843 changed files with 288489 additions and 248355 deletions

View File

@@ -1,7 +1,7 @@
<p>给你一个只包含小写字母的字符串&nbsp;<code>s</code>&nbsp;,你需要找到 <code>s</code>&nbsp;中最多数目的非空子字符串,满足如下条件:</p>
<ol>
<li>这些字符串之间互不重叠,也就是说对于任意两个子字符串&nbsp;<code>s[i..j]</code>&nbsp;<code>s[k..l]</code>&nbsp;,要么&nbsp;<code>j &lt; k</code>&nbsp;要么&nbsp;<code>i &gt; l</code>&nbsp;</li>
<li>这些字符串之间互不重叠,也就是说对于任意两个子字符串&nbsp;<code>s[i..j]</code>&nbsp;<code>s[x..y]</code>&nbsp;,要么&nbsp;<code>j &lt; x</code>&nbsp;要么&nbsp;<code>i &gt; y</code>&nbsp;</li>
<li>如果一个子字符串包含字符&nbsp;<code>char</code> ,那么&nbsp;<code>s</code>&nbsp;中所有&nbsp;<code>char</code> 字符都应该在这个子字符串中。</li>
</ol>
@@ -13,25 +13,27 @@
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>s = &quot;adefaddaccc&quot;
<strong></strong>[&quot;e&quot;,&quot;f&quot;,&quot;ccc&quot;]
<pre>
<strong></strong>s = "adefaddaccc"
<strong>输出:</strong>["e","f","ccc"]
<strong>解释:</strong>下面为所有满足第二个条件的子字符串:
[
&nbsp; &quot;adefaddaccc&quot;
&nbsp; &quot;adefadda&quot;,
&nbsp; &quot;ef&quot;,
&nbsp; &quot;e&quot;,
&quot;f&quot;,
&nbsp; &quot;ccc&quot;,
&nbsp; "adefaddaccc"
&nbsp; "adefadda",
&nbsp; "ef",
&nbsp; "e",
"f",
&nbsp; "ccc",
]
如果我们选择第一个字符串,那么我们无法再选择其他任何字符串,所以答案为 1 。如果我们选择 &quot;adefadda&quot; ,剩下子字符串中我们只可以选择 &quot;ccc&quot; ,它是唯一不重叠的子字符串,所以答案为 2 。同时我们可以发现,选择 &quot;ef&quot; 不是最优的,因为它可以被拆分成 2 个子字符串。所以最优解是选择 [&quot;e&quot;,&quot;f&quot;,&quot;ccc&quot;] ,答案为 3 。不存在别的相同数目子字符串解。
如果我们选择第一个字符串,那么我们无法再选择其他任何字符串,所以答案为 1 。如果我们选择 "adefadda" ,剩下子字符串中我们只可以选择 "ccc" ,它是唯一不重叠的子字符串,所以答案为 2 。同时我们可以发现,选择 "ef" 不是最优的,因为它可以被拆分成 2 个子字符串。所以最优解是选择 ["e","f","ccc"] ,答案为 3 。不存在别的相同数目子字符串解。
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>s = &quot;abbaccd&quot;
<strong></strong>[&quot;d&quot;,&quot;bb&quot;,&quot;cc&quot;]
<strong>解释</strong>注意到解 [&quot;d&quot;,&quot;abba&quot;,&quot;cc&quot;] 答案也为 3 ,但它不是最优解,因为它的总长度更长。
<pre>
<strong></strong>s = "abbaccd"
<strong>输出</strong>["d","bb","cc"]
<strong>解释:</strong>注意到解 ["d","abba","cc"] 答案也为 3 ,但它不是最优解,因为它的总长度更长。
</pre>
<p>&nbsp;</p>