Maximize Substring with Character Changes
STRING
HASH TABLE
Problem
Given a string s
and an integer k
, determine the maximum length of a substring where all characters are the same after modifying up to k
characters.
You can replace any character in the string with another uppercase English character to achieve this.
Examples
maxSubstring("AAABBC", 2) // return 5 // Why? You can form "AAAAAC" by replacing two Bs maxSubstring("ABCDE", 0) // return 1 /* Why? With no changes allowed (k = 0), longest substring with repeating characters is 1 */
Loading...
Loading...Loading...