Longest Repeating Character Replacement
You may replace at most k characters of s with uppercase letters. Return the greatest length of a contiguous substring that can become one repeated letter.
Example 1
s = "ABBBAC"
k = 14Explanation
Replacing the first A in ABBB gives four B letters; no length-five window needs only one change.
Example 2
s = "ABCDE"
k = 23Explanation
Any three distinct letters can become equal with two changes; four need three.
Example 3
s = "AAAA"
k = 04Explanation
The whole string already contains only A, requiring no replacements.
Constraints
- 0 <= len(s) <= 100000
- s contains uppercase English letters
- 0 <= k <= len(s)
Function contract
characterReplacementArguments: json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
"ABBBAC"1