← Roblox Interview Insights

Roblox·Data Scientist·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026Remote

Summary

Roblox data scientist interview with a meaty coding problem disguised as a metrics question. The problem sounded like a straightforward CTR/RPM aggregation until you actually read the constraints.

Questions Asked (1)

Q1

Write a Python function that computes per-day, per-campaign CTR and RPM from a stream of ad events, where clicks can be duplicated per request ID, impressions can arrive after clicks, and events may be out of order. You must deduplicate impressions and clicks correctly, handle bad records gracefully, and stay within O(U) memory where U is the number of active request IDs in a 24-hour window.

Algorithms & Data StructuresProduct Analytics & MetricsSystem Design
Author's notes

This looked like a data engineering question wearing a data science costume.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the event schema and defining deduplication keys (request_id for impressions, click_id for clicks). Design a streaming solution using a dictionary to track seen IDs within a 24-hour window, aggregating counts per day and campaign, and evicting old entries to maintain O(U) memory. Handle bad records by logging and skipping them, and compute CTR and RPM as clicks/impressions and revenue/impressions*1000 respectively.

Pro tip: Emphasize the importance of a sliding window for deduplication and discuss trade-offs between exact and approximate deduplication (e.g., Bloom filters) when memory is constrained.

1. Clarify Requirements and Assumptions

Ask about event schema, definitions of CTR and RPM, and the 24-hour window semantics. Confirm that deduplication is based on request_id for impressions and click_id for clicks.

2. Design Data Structures for Deduplication and Aggregation

Use a dictionary to store seen request_ids and click_ids with timestamps for eviction. Maintain nested dictionaries for per-day, per-campaign counts of impressions, clicks, and revenue.

3. Process Events in a Streaming Fashion

For each event, validate fields, check for duplicates using the appropriate ID, update aggregates if new, and handle out-of-order events by allowing late arrivals within the window.

4. Implement Eviction and Memory Management

Periodically evict entries older than 24 hours from the deduplication dictionary to keep memory O(U). Use a time-based cleanup or a deque for efficient eviction.

5. Compute and Output Metrics

Calculate CTR as clicks/impressions and RPM as (revenue/impressions)*1000 for each day and campaign. Ensure division by zero is handled gracefully.

Key Points to Mention

  • Deduplication strategy using request_id for impressions and click_id for clicks
  • Handling out-of-order events by allowing late arrivals within the 24-hour window
  • Memory management: O(U) where U is the number of active request IDs in the window
  • Graceful handling of bad records (e.g., missing fields, invalid values) by logging and skipping
  • Definition of CTR (clicks/impressions) and RPM (revenue/impressions*1000)
  • Trade-offs between exact and approximate deduplication (e.g., Bloom filters) for scalability

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.