This is a verified interview question from Citadel. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Minimum Idleness - Citadel Online Assessment" covers key patterns like Other.
"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 ith 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 = "aabbbbaaa", 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."
Join thousands of developers practicing for Citadel.