Company: Publicis_Sapient_9_jan
Difficulty: medium
Shader Loader A game renders shaders using two GPUs: a and b . A string shader represents which GPU is used for each render, 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 = "aabbbaaaaa" switchCount = 2 An optimal solution: Switch shader[3] to get "aababaaaaa" Switch shader[6] to get "aabababaab" Now shader = "aabababaab" , and the system has an idleness of 2. The groups