Class Solution
java.lang.Object
g0401_0500.s0424_longest_repeating_character_replacement.Solution
424 - Longest Repeating Character Replacement.<p>Medium</p>
<p>You are given a string <code>s</code> and an integer <code>k</code>. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most <code>k</code> times.</p>
<p>Return <em>the length of the longest substring containing the same letter you can get after performing the above operations</em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “ABAB”, k = 2</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Explanation:</strong> Replace the two ’A’s with two ’B’s or vice versa.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “AABABBA”, k = 1</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Explanation:</strong> Replace the one ‘A’ in the middle with ‘B’ and form “AABBBBA”. The substring “BBBB” has the longest repeating letters, which is 4.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length <= 10<sup>5</sup></code></li>
<li><code>s</code> consists of only uppercase English letters.</li>
<li>`0 <= k <= s.length</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
characterReplacement
-