mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个字符串 <code>s</code> ,请你返回满足以下条件且出现次数最大的 <strong>任意</strong> 子串的出现次数:</p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li>子串中不同字母的数目必须小于等于 <code>maxLetters</code> 。</li>
 | 
						||
	<li>子串的长度必须大于等于 <code>minSize</code> 且小于等于 <code>maxSize</code> 。</li>
 | 
						||
</ul>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>s = "aababcaab", maxLetters = 2, minSize = 3, maxSize = 4
 | 
						||
<strong>输出:</strong>2
 | 
						||
<strong>解释:</strong>子串 "aab" 在原字符串中出现了 2 次。
 | 
						||
它满足所有的要求:2 个不同的字母,长度为 3 (在 minSize 和 maxSize 范围内)。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>s = "aaaa", maxLetters = 1, minSize = 3, maxSize = 3
 | 
						||
<strong>输出:</strong>2
 | 
						||
<strong>解释:</strong>子串 "aaa" 在原字符串中出现了 2 次,且它们有重叠部分。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 3:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>s = "aabcabcab", maxLetters = 2, minSize = 2, maxSize = 3
 | 
						||
<strong>输出:</strong>3
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 4:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>s = "abcde", maxLetters = 2, minSize = 3, maxSize = 3
 | 
						||
<strong>输出:</strong>0
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= s.length <= 10^5</code></li>
 | 
						||
	<li><code>1 <= maxLetters <= 26</code></li>
 | 
						||
	<li><code>1 <= minSize <= maxSize <= min(26, s.length)</code></li>
 | 
						||
	<li><code>s</code> 只包含小写英文字母。</li>
 | 
						||
</ul>
 |