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)/至少有 K 个重复字符的最长子串 [longest-substring-with-at-least-k-repeating-characters].html

31 lines
1008 B
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> 和一个整数 <code>k</code> ,请你找出 <code>s</code> 中的最长子串,&nbsp;要求该子串中的每一字符出现次数都不少于 <code>k</code> 。返回这一子串的长度。</p>
<p data-pm-slice="1 1 []">如果不存在这样的子字符串,则返回 0。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "aaabb", k = 3
<strong>输出:</strong>3
<strong>解释:</strong>最长子串为 "aaa" ,其中 'a' 重复了 3 次。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "ababbc", k = 2
<strong>输出:</strong>5
<strong>解释:</strong>最长子串为 "ababb" ,其中 'a' 重复了 2 次, 'b' 重复了 3 次。</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 10<sup>4</sup></code></li>
<li><code>s</code> 仅由小写英文字母组成</li>
<li><code>1 &lt;= k &lt;= 10<sup>5</sup></code></li>
</ul>