Find Members Who Rewatch the Same Title Within K Days
Last updated: November 29, 2026
Quick Overview
Given viewing events as (member_id, title_id, day) tuples in arbitrary order, return every member who started the same title at least twice with a gap of at most k days between two consecutive starts.
Netflix
November 29, 20260
0
0 solved
Given viewing events as (member_id, title_id, day) tuples in arbitrary order, return every member who started the same title at least twice with a gap of at most k days between two consecutive starts.
Rewatch behavior is a strong signal for Netflix's personalization and for deciding which titles keep a long tail of engagement. This is a warm-up style phone screen question: the interviewer wants a clean hash map solution, clear handling of unsorted input, and crisp reasoning about why only consecutive starts matter.
What the Interviewer Expects
- Clarify whether the input is sorted and whether the gap is inclusive
- Key a hash map on the (member, title) pair, not on member alone
- Explain why comparing only to the most recent prior start is sufficient
- Give O(n log n) with sorting, or O(n) if events arrive time-ordered
- Return a deterministic, de-duplicated result
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
- How would you change this if events stream in and you must flag members in real time?
- What if you need the count of rewatched titles per member instead of a yes or no?
- How would you exclude rewatches that are really a resumed session from the same night?
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 is a list of (member_id, title_id, day) events, not necessarily sorted. A member qualifies if, for some title, two starts are at most k days apart (inclusive). Output is the sorted list of quali...
High-Level Design
Sort by day so that for each (member, title) we only need to compare a new start with the most recent previous start. If any pair of starts is within k days, then some consecutive pair is too, because...