Company: Expedia
Difficulty: hard
A game renders shaders using two GPUs: a and b . String shader represents which GPU is used for each shader, where shader[i] = 'a' means GPU a is used for the i th shader, and shader[i] = 'b' means GPU b is used. The idleness of this dual GPU system is defined as the maximum number of shaders for which the same GPU is used consecutively. For example, in shader = "aabbba" , GPU a is used for 2 consecutive shaders, then GPU b for 3 consecutive shaders, then GPU a for 1 shader. The idleness of this system is 3. To reduce idleness, you can perform the following operation at most switchCount times: Select any index i and change shader[i] from 'a' to 'b' or vice versa. Find the minimum possible idleness that can be achieved by applying these operations optimally. Example shader = "aabbbaaaa" switchCount = 2 An optimal solution: Switch shader[3] to get "aababaaaa" Switch shader[6] to get "aabababaa" Now shader = "aabababaa" , and the system has an idleness of 2. Input Format The first line co