Get Minimum Time ⏰
Learn this problemProblem statement
There are n services numbered from 1 to n in a system, and there are m requests to be processed.
The service in which the ith request is cached is denoted by cache[i], for all 1 <= i <= m. For any request, if the request is processed from a cache, then it takes 1 unit of time.
Otherwise, it takes 2 units of time.
Different services can process different requests simultaneously, but one service can only process one request at a time. Find the minimum time to process all the requests by allocating each request to a service.
Function
getMinTime(n: int, cache: int[]) → int
Complete the function getMinTime in the editor.
getMinTime has the following parameters:
int n: the number of services in the systemint cache[m]: the service in which the request is cached
Returns
int: the minimum time required to process all requests
Examples
Example 1
n = 3cache = [1, 1, 3, 1, 1]return = 3Constraints
Unknown for now 👉👈