PracHub
QuestionsPremiumLearningGuidesCheatsheetNEW
|Home/Coding & Algorithms/Roblox

Extend counter to per-client rate limiting

Last updated: Mar 29, 2026

Quick Overview

This question evaluates competency in designing per-client, time-windowed rate limiting using efficient data structures for time-based eviction and counting within the Coding & Algorithms domain.

  • easy
  • Roblox
  • Coding & Algorithms
  • Machine Learning Engineer

Extend counter to per-client rate limiting

Company: Roblox

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are extending the recent-requests counter to support **per-client** rate limiting. Each request now includes a `clientId` identifying the caller. You must track hits separately for each client, still over the last 5 minutes. Design and implement a class that supports the following operations: - `void hit(String clientId, int timestamp)` Records a hit from `clientId` at time `timestamp` (in seconds). Assumptions: - Timestamps are given in **strictly increasing** order across all calls. - There may be multiple hits from the same or different clients at the same `timestamp`. - `int getHits(String clientId, int timestamp)` Returns the number of hits made by this specific `clientId` in the **past 5 minutes**, i.e., in the inclusive interval `[timestamp - 299, timestamp]`. Additional requirements and constraints: - The system may have **many distinct clients**; most of them will be idle at any given time. - You only need to keep data that is at most 5 minutes old per client; older hits for that client should be discarded or ignored. - Aim for time complexity close to O(1) **amortized** per operation and space proportional to the number of hits in the last 5 minutes. - Your design should be efficient both when there is a single very active client and when there are many moderately active clients. Define the class interface and implement the methods `hit` and `getHits`.

Quick Answer: This question evaluates competency in designing per-client, time-windowed rate limiting using efficient data structures for time-based eviction and counting within the Coding & Algorithms domain.

Related Interview Questions

  • Implement Sliding-Window Rate Limiter - Roblox (medium)
  • Find target-heavy sliding windows - Roblox (medium)
  • Find most frequent call path in logs - Roblox (medium)
  • Track Highest-Earning Experience - Roblox (medium)
  • Find the Most Frequent Log Call - Roblox (easy)
Roblox logo
Roblox
Dec 8, 2025, 7:56 PM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
5
0

You are extending the recent-requests counter to support per-client rate limiting.

Each request now includes a clientId identifying the caller. You must track hits separately for each client, still over the last 5 minutes.

Design and implement a class that supports the following operations:

  • void hit(String clientId, int timestamp)
    Records a hit from clientId at time timestamp (in seconds).
    Assumptions:
    • Timestamps are given in strictly increasing order across all calls.
    • There may be multiple hits from the same or different clients at the same timestamp .
  • int getHits(String clientId, int timestamp)
    Returns the number of hits made by this specific clientId in the past 5 minutes , i.e., in the inclusive interval [timestamp - 299, timestamp] .

Additional requirements and constraints:

  • The system may have many distinct clients ; most of them will be idle at any given time.
  • You only need to keep data that is at most 5 minutes old per client; older hits for that client should be discarded or ignored.
  • Aim for time complexity close to O(1) amortized per operation and space proportional to the number of hits in the last 5 minutes.
  • Your design should be efficient both when there is a single very active client and when there are many moderately active clients.

Define the class interface and implement the methods hit and getHits.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Roblox•More Machine Learning Engineer•Roblox Machine Learning Engineer•Roblox Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.