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)/包含所有三种字符的子字符串数目 [number-of-substrings-containing-all-three-characters].html
2022-03-29 12:43:11 +08:00

35 lines
1.4 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>&nbsp;,它只包含三种字符 a, b 和 c 。</p>
<p>请你返回 ab 和 c 都&nbsp;<strong>至少&nbsp;</strong>出现过一次的子字符串数目。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>s = &quot;abcabc&quot;
<strong>输出:</strong>10
<strong>解释:</strong>包含 ab 和 c 各至少一次的子字符串为<em> &quot;</em>abc<em>&quot;, &quot;</em>abca<em>&quot;, &quot;</em>abcab<em>&quot;, &quot;</em>abcabc<em>&quot;, &quot;</em>bca<em>&quot;, &quot;</em>bcab<em>&quot;, &quot;</em>bcabc<em>&quot;, &quot;</em>cab<em>&quot;, &quot;</em>cabc<em>&quot; </em><em> &quot;</em>abc<em>&quot; </em>(<strong>相同</strong><strong>字符串算多次</strong>)<em></em>
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>s = &quot;aaacb&quot;
<strong>输出:</strong>3
<strong>解释:</strong>包含 ab 和 c 各至少一次的子字符串为<em> &quot;</em>aaacb<em>&quot;, &quot;</em>aacb<em>&quot; </em><em> &quot;</em>acb<em>&quot;</em>
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>s = &quot;abc&quot;
<strong>输出:</strong>1
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>3 &lt;= s.length &lt;= 5 x 10^4</code></li>
<li><code>s</code>&nbsp;只包含字符 ab 和 c 。</li>
</ul>