Flag Duplicate Ride Requests From the Same Rider Within Seconds
Last updated: November 29, 2026
Quick Overview
Given a chronologically ordered list of ride requests as (rider_id, timestamp_seconds), return the indices of requests that arrive within k seconds of a previous request from the same rider so they can be deduplicated.
Uber
November 29, 20260
0
0 solved
Given a chronologically ordered list of ride requests as (rider_id, timestamp_seconds), return the indices of requests that arrive within k seconds of a previous request from the same rider so they can be deduplicated.
Uber phone screens often open with a short hashing warm-up tied to a real dispatch concern, here the double-tap that creates two ride requests. The interviewer checks that you reach for a hash map keyed by rider, state the window semantics precisely, and finish quickly enough to leave time for a follow-up.
What the Interviewer Expects
- Clarify whether the window compares against the last request or the last accepted request
- Use a dictionary from rider_id to last seen timestamp
- Run in a single linear pass
- Handle the boundary case where the gap equals exactly k
- Explain the memory growth and how to bound it
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- What if requests can arrive slightly out of order (up to 2 seconds late)?
- How would you bound memory for millions of riders in a streaming service?
- What if a duplicate should only be flagged when pickup locations are also within 50 meters?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: list of
(rider_id, ts)sorted byts, and an integerk(seconds). - A request is a duplicate if the same rider has an earlier request with
ts - prev_ts <= k. - Clarify: compare against...
High-Level Design
Because the input is time ordered, the only fact we need per rider is the timestamp of their most recent request. A dictionary last[rider] = ts gives O(1) lookup. For each request we check the gap, ...