Algorithm · Salesforce · Medium
A video game employs two GPUs, labeled a and b, to process shaders. The string shader indicates which GPU is assigned to each shader position: shader[i] is either 'a' or 'b'. The idleness metric of the system is defined as the length of the longest consecutive block where the same GPU is used. For instance, in "aaabba", the longest run is 3 (for the initial 'a' block). You are allowed to perform at most switchCount operations. In one operation, you may pick any index and…
Checking your access…