ibm logo
IBM· Data Science

IBM CODING ASSESSMENT - IBM US - Standard - Data Science

Location
US
Posted
31 Mar 2025
507 reads

Summary

I participated in an IBM US coding assessment for a Data Science role, which focused on designing an API rate-limiting system.

How it went

My coding assessment for IBM US, intended for a Data Science position, required me to design and implement an API rate-limiting system according to specified constraints. The problem statement detailed the requirements for handling incoming domain requests within various time windows, checking both 5-second and 30-second limits.

Questions asked (1)

  1. 01

    API Rate Limiting System

    Data Structures & Algorithms · Hard

    You are tasked with designing an API rate-limiting system that processes incoming requests while enforcing request limits. Given an array of domain requests, each request occurs at a specific second. The API gateway applies the following rate limits:

    • A domain can make at most 2 requests within a 5-second window.
    • A domain can make at most 5 requests within a 30-second window.

    Write a function getDomainRequestStatus(requests) that determines whether each request can be processed. The function should return:

    • {status: 200, message: OK} if the request is allowed.
    • {status: 429, message: Too many requests} if the request exceeds the rate limit.

    Input Format

    • requests: A list of domain names representing incoming requests.

    Example

    requests = ["www.xyz.com", "www.abc.com", "www.xyz.com", "www.pqr.com", "www.abc.com", "www.xyz.com", "www.xyz.com"]
    print(getDomainRequestStatus(requests))
    

    Expected Output

    ["{status: 200, message: OK}", 
     "{status: 200, message: OK}", 
     "{status: 200, message: OK}", 
     "{status: 200, message: OK}", 
     "{status: 200, message: OK}", 
     "{status: 200, message: OK}", 
     "{status: 429, message: Too many requests}"]
    

    Constraints

    • The function should efficiently track request timestamps for each domain.
    • It should remove outdated requests beyond the 30-second window.
    • It must check both 5-second and 30-second limits before allowing a request.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at IBM recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!