Panda Guru LogoPanda
Guru

Salesforce OA

Round 1

Questions: A game's shaders are rendered using two GPUs: a and b. There is a string, which represents that for the f shader in which a GPU 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, for the string shader = "aalbbba", for the first 2 seconds, GPU a is used then for the next 3 seconds, GPU b is used, then for 1 second, GPU a is used. Hence, the idleness of the system is 3.

In order to reduce the idleness of the system, the following operation can be used at most switchCount times:

Find the minimum possible idleness of the system that can be achieved by applying the operations optimally.

Example: It is given that shader = "aabbbaaaa" and switchCount=2. One optimal solution is:

Now shader "aabababaa", and the system has an idleness of 2.

Was only able to pass 2 test cases with the sliding window method. Any suggestions would be helpful.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.