1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/统计同构子字符串的数目 [count-number-of-homogenous-substrings].html
2022-03-29 12:43:11 +08:00

43 lines
1.3 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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> ,返回<em> </em><code>s</code><em> </em><strong>同构子字符串</strong> 的数目。由于答案可能很大,只需返回对 <code>10<sup>9</sup> + 7</code> <strong>取余 </strong>后的结果。</p>
<p><strong>同构字符串</strong> 的定义为:如果一个字符串中的所有字符都相同,那么该字符串就是同构字符串。</p>
<p><strong>子字符串</strong> 是字符串中的一个连续字符序列。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>s = "abbcccaa"
<strong>输出:</strong>13
<strong>解释:</strong>同构子字符串如下所列:
"a" 出现 3 次。
"aa" 出现 1 次。
"b" 出现 2 次。
"bb" 出现 1 次。
"c" 出现 3 次。
"cc" 出现 2 次。
"ccc" 出现 1 次。
3 + 1 + 2 + 1 + 3 + 2 + 1 = 13</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>s = "xy"
<strong>输出:</strong>2
<strong>解释:</strong>同构子字符串是 "x" 和 "y" 。</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>s = "zzzzz"
<strong>输出:</strong>15
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
<li><code>s</code> 由小写字符串组成</li>
</ul>