mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<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 <= s.length <= 10<sup>5</sup></code></li>
 | 
						||
	<li><code>s</code> 由小写字符串组成</li>
 | 
						||
</ul>
 |