Rate-Limiting Algorithm
Some developers at Amazon are building a prototype for a simple rate-limiting algorithm. There are n requests to be processed by the server, represented by a string requests, where the i-th character represents the region of the i-th client. Each request takes 1 unit of time to process.
There must be a minimum time gap of minGap units between any two requests from the same region.
Complete the function getMinTime in the editor.
getMinTime has the following parameters:
n: int: the number of requestsrequests: String: a string representing the region of each requestminGap: int: the minimum time gap required between requests from the same region
Returns
The function should return an integer representing the minimum time required to process all requests without denial.
1Example 1

2Example 2
Constraints
Limits and guarantees your solution can rely on.
1 <= length of requests <= 1050 <= minGap <= 100It is guaranteed that requests contain lowercase English characters