1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/拆分字符串使唯一子字符串的数目最大 [split-a-string-into-the-max-number-of-unique-substrings].html
2022-03-29 12:43:11 +08:00

42 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串 <code>s</code> ,请你拆分该字符串,并返回拆分后唯一子字符串的最大数目。</p>
<p>字符串 <code>s</code> 拆分后可以得到若干 <strong>非空子字符串</strong> ,这些子字符串连接后应当能够还原为原字符串。但是拆分出来的每个子字符串都必须是 <strong>唯一的</strong></p>
<p>注意:<strong>子字符串</strong> 是字符串中的一个连续字符序列。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>s = &quot;ababccc&quot;
<strong>输出:</strong>5
<strong>解释:</strong>一种最大拆分方法为 [&#39;a&#39;, &#39;b&#39;, &#39;ab&#39;, &#39;c&#39;, &#39;cc&#39;] 。像 [&#39;a&#39;, &#39;b&#39;, &#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;cc&#39;] 这样拆分不满足题目要求,因为其中的 &#39;a&#39;&#39;b&#39; 都出现了不止一次。
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>s = &quot;aba&quot;
<strong>输出:</strong>2
<strong>解释:</strong>一种最大拆分方法为 [&#39;a&#39;, &#39;ba&#39;] 。
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>s = &quot;aa&quot;
<strong>输出:</strong>1
<strong>解释:</strong>无法进一步拆分字符串。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>
<p><code>1 &lt;= s.length&nbsp;&lt;= 16</code></p>
</li>
<li>
<p><code>s</code> 仅包含小写英文字母</p>
</li>
</ul>