๐Ÿšฆ

Rate Limiter

Allow at most N requests per time window โ€” the logic behind every API.

Project 11Advanced

๐Ÿงฉ Problem statement

Allow at most N requests per time window โ€” the logic behind every API. Design it completely in pseudocode first: plan the data, split the work into functions, write the logic, dry-run it and test it.

๐Ÿ“‹ Requirements

  • Time windows
  • Counters
  • State
  • Queue of timestamps

๐Ÿ“ฅ Inputs

  • Request times

๐Ÿ“ค Outputs

  • Allowed / blocked for each request

๐Ÿ“ Rules

  • At most 5 requests in any 10-second window

๐Ÿšง Constraints

  • Times arrive in increasing order

๐Ÿงญ Suggested approach

  • Restate the problem in your own words
  • List the data you must remember (variables, lists, maps)
  • Write one FUNCTION per feature
  • Write the main program that calls them
  • Dry-run with the Run button
  • Test normal cases and edge cases

๐Ÿง  Required concepts

  • Data structures
  • Algorithms
  • Complexity
โœ๏ธ Pseudocode editor ยท dry-run tool ยท test cases

Design your solution here. Use Run to dry-run it step by step. Hints unlock one at a time โ€” try on your own first!

๐Ÿงช Edge cases to test

  • Empty input
  • Very large values
  • Repeated or duplicate entries

๐Ÿš€ Challenge extensions

  • Add a feature of your own
  • Make it work for 10ร— more data โ€” what changes?

โ† All projects