Try to solve the Longest Repeating Character Replacement problem.
We'll cover the following
Statement
Given a string s
and an integer k
, find the length of the longest substring in s
, where all characters are identical, after replacing, at most, k
characters with any other lowercase English character.
Constraints:
-
s.length
s
consists of only lowercase English characters-
k
s.length
Example
1 of 4
Understand the problem
Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Longest Repeating Character Replacement
1
What is the correct output for the following input values?
“abab”,
A)
1
B)
2
C)
3
D)
4
Question 1 of 30 attempted
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Try it yourself
Implement your solution in the following coding playground.
JavaScript
usercode > main.js
function longestRepeatingCharacterReplacement(s, k) {// Replace this placeholder return statement with your codereturn -1;}export { longestRepeatingCharacterReplacement };
Click "Run" to evaluate your code.
Longest Repeating Character Replacement