Company: Citadel Securities Software Engineering On-campus_14july

Difficulty: medium

Problem Statement

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 for the i th shader . The idleness of a d ual 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 G PU 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 chan g e 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. Function De

More Citadel Securities Software Engineering On-campus_14july OA questionsInterview experiences