Company: LinkedIn_coachin_11_jan
Difficulty: medium
Dual Cache Minimum Payload Problem Description You are analyzing the performance of a dual cache system that processes n service requests. For each request i : payloadSize[i] is the size of the request. cacheA[i] = 1 if cache A can serve request i , otherwise 0. cacheB[i] = 1 if cache B can serve request i , otherwise 0. You want to select a subset of requests such that: Cache A can serve at least minThreshold of the selected requests. Cache B can serve at least minThreshold of the selected requests. Among all such valid subsets, you must find the one with the minimum possible sum of payload sizes. Return: the minimum sum of payload sizes of such a subset, or -1 if no such subset exists. Example 1 Input: n = 6 payloadSize = [10, 8, 12, 4, 5, 25] cacheA = [1, 0, 1, 1, 0, 1] cacheB = [1, 0, 1, 0, 1, 1] minThreshold = 3 Output: 31 Explanation: If we choose the subset {1 st , 3 rd , 4 th , 5 th } requests: Cache A can serve the 1 st , 3 rd , and 4 th requests (3 requests, meeting the thres