57. Repetition with Swaps
Medium
Given a string texto of uppercase letters and an integer k, you may replace up to k characters in any contiguous substring with another uppercase letter. Return the maximum length of a substring that can be made of a single letter.
Example 1
Input: texto = "AABABBA", k = 1
Output: 4
Example 2
Input: texto = "ABBB", k = 2
Output: 4
Constraints
- 1 <= texto.length <= 10^5
- 0 <= k <= texto.length
- texto contains only uppercase ASCII letters.
StringsSliding window
Saved in this browser
Caso 1
texto =
"AABABBA"
k =
1
Expected =
4
Caso 2
texto =
"ABBB"
k =
2
Expected =
4
Run checks these 2 cases. Submit runs all 6, including hidden ones.