Back to problems

Find longest uniform substring after k replacements

Algorithm · Apple · Medium

Given a string s consisting of ASCII characters and an integer k, return the maximum length of a contiguous substring that can be transformed so that all its characters are the same, by changing no more than k characters in the substring. Each changed character may be replaced with any character. If s is empty, return 0. Example 1: Explanation: The substring AABA has three A characters and one B; replacing that B with A yields AAAA. No length-5 substring in this string can…

Checking your access…