mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
<p>Given a string <code>s</code> of lowercase letters, you need to find the maximum number of <strong>non-empty</strong> substrings of <code>s</code> that meet the following conditions:</p>
|
||||
<p>Given a string <code>s</code> of lowercase letters, you need to find the maximum number of <strong>non-empty</strong> substrings of <code>s</code> that meet the following conditions:</p>
|
||||
|
||||
<ol>
|
||||
<li>The substrings do not overlap, that is for any two substrings <code>s[i..j]</code> and <code>s[k..l]</code>, either <code>j < k</code> or <code>i > l</code> is true.</li>
|
||||
<li>A substring that contains a certain character <code>c</code> must also contain all occurrences of <code>c</code>.</li>
|
||||
<li>The substrings do not overlap, that is for any two substrings <code>s[i..j]</code> and <code>s[x..y]</code>, either <code>j < x</code> or <code>i > y</code> is true.</li>
|
||||
<li>A substring that contains a certain character <code>c</code> must also contain all occurrences of <code>c</code>.</li>
|
||||
</ol>
|
||||
|
||||
<p>Find <em>the maximum number of substrings that meet the above conditions</em>. If there are multiple solutions with the same number of substrings, <em>return the one with minimum total length. </em>It can be shown that there exists a unique solution of minimum total length.</p>
|
||||
<p>Find <em>the maximum number of substrings that meet the above conditions</em>. If there are multiple solutions with the same number of substrings, <em>return the one with minimum total length. </em>It can be shown that there exists a unique solution of minimum total length.</p>
|
||||
|
||||
<p>Notice that you can return the substrings in <strong>any</strong> order.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "adefaddaccc"
|
||||
@@ -27,7 +27,7 @@
|
||||
If we choose the first string, we cannot choose anything else and we'd get only 1. If we choose "adefadda", we are left with "ccc" which is the only one that doesn't overlap, thus obtaining 2 substrings. Notice also, that it's not optimal to choose "ef" since it can be split into two. Therefore, the optimal way is to choose ["e","f","ccc"] which gives us 3 substrings. No other solution of the same number of substrings exist.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "abbaccd"
|
||||
@@ -39,6 +39,6 @@ If we choose the first string, we cannot choose anything else and we'd get o
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= s.length <= 10^5</code></li>
|
||||
<li><code>s</code> contains only lowercase English letters.</li>
|
||||
<li><code>1 <= s.length <= 10<sup>5</sup></code></li>
|
||||
<li><code>s</code> contains only lowercase English letters.</li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user