mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
35 lines
1.4 KiB
HTML
35 lines
1.4 KiB
HTML
<p>给你一个字符串 <code>s</code> ,它只包含三种字符 a, b 和 c 。</p>
|
||
|
||
<p>请你返回 a,b 和 c 都 <strong>至少 </strong>出现过一次的子字符串数目。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>s = "abcabc"
|
||
<strong>输出:</strong>10
|
||
<strong>解释:</strong>包含 a,b 和 c 各至少一次的子字符串为<em> "</em>abc<em>", "</em>abca<em>", "</em>abcab<em>", "</em>abcabc<em>", "</em>bca<em>", "</em>bcab<em>", "</em>bcabc<em>", "</em>cab<em>", "</em>cabc<em>" </em>和<em> "</em>abc<em>" </em>(<strong>相同</strong><strong>字符串算多次</strong>)<em>。</em>
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>s = "aaacb"
|
||
<strong>输出:</strong>3
|
||
<strong>解释:</strong>包含 a,b 和 c 各至少一次的子字符串为<em> "</em>aaacb<em>", "</em>aacb<em>" </em>和<em> "</em>acb<em>" 。</em>
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>s = "abc"
|
||
<strong>输出:</strong>1
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>3 <= s.length <= 5 x 10^4</code></li>
|
||
<li><code>s</code> 只包含字符 a,b 和 c 。</li>
|
||
</ul>
|