Find Minimum Time Required (Amazon Bangalore :)
Learn this problemProblem statement
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 ith character represents the region of the ith 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.
The requests can be sent in any order and there can be gaps in transmission for testing purposes. Find the minimum amount of time required to process all the requests such that no request is denied.
Function
findMinimumTimeRequired(requests: String, minGap: int) → int
Complete the function findMinimumTimeRequired in the editor.
findMinimumTimeRequired has the following parameters:
- 1.
String requests: a string where each character represents the region of a client - 2.
int minGap: the minimum time gap required between two requests from the same region
Returns
int: the minimum amount of time required to process all requests
Examples
Example 1
requests = "abacadaeafag"minGap = 2return = 16Example 2
requests = "aaabbb"minGap = 0return = 6Example 3
requests = "aaabbb"minGap = 2return = 8
Constraints
🍓More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026