Company: UKG
Difficulty: medium
Dual Cache Performance A team is doing an analysis of a dual cache performance. There are n requests in the queue to be processed by a service where the payload size of the i th request is denoted by payloadSize[i]. There are two caches A and B in the service which cache the response to requests made. If the i th request is cached by cache A, then cacheA[i] = 1, otherwise 0 for all 1 ≤ i ≤ n If the i th request is cached by cache B, then cacheB[i] = 1, otherwise 0 for all 1 ≤ i ≤ n Find the minimum sum of the payload sizes of a subset of requests in which each cache can serve at least minThreshold requests, or return -1 if they cannot. Function Description Complete the function getMinimumSize with the following parameters: int payloadSize[n] : the payload sizes of the requests int cacheA[n] : the requests which are cached in cache A int cacheB[n] : the requests which are cached in cache B int minThreshold : minimum number of requests each cache must serve Returns long : the minimum sum