Rate-Limiting Algorithm

Problem Overview

  • Compute the minimum total time to process requests so same-region requests are at least minGap apart; each takes 1 unit.
  • Input: n, requests string (lowercase, length <= 1e5), minGap; Output: minimal total time (int).
  • Requests may be reordered, and idle gaps are allowed to satisfy server rate-limiting in a scheduling context.
  • An Amazon coding interview problem and a common interview question from Amazon interviews.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: