ByteByteGo logo
menuProblems List

Longest Uniform Substring After Replacements

Hard

A uniform substring is one in which all characters are identical. Given a string, determine the length of the longest uniform substring that can be formed by replacing up to k characters.

Example:

Input: s = 'aabcdcca', k = 2
Output: 5

Explanation: if we can only replace 2 characters, the longest uniform substring we can achieve is "ccccc", obtained by replacing 'b' and 'd' with 'c'.

You can practice coding exercises online by logging into bytebytego.com on your laptop.