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)/替换后的最长重复字符 [longest-repeating-character-replacement].html
2022-03-29 12:43:11 +08:00

34 lines
1020 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>k</code> 次。</p>
<p>在执行上述操作后,返回包含相同字母的最长子字符串的长度。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "ABAB", k = 2
<strong>输出:</strong>4
<strong>解释:</strong>用两个'A'替换为两个'B',反之亦然。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "AABABBA", k = 1
<strong>输出:</strong>4
<strong>解释:</strong>
将中间的一个'A'替换为'B',字符串变为 "AABBBBA"。
子串 "BBBB" 有最长重复字母, 答案为 4。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
<li><code>s</code> 仅由大写英文字母组成</li>
<li><code>0 &lt;= k &lt;= s.length</code></li>
</ul>