Compute Resume Positions From Playback Heartbeats

Last updated: November 29, 2026

Quick Overview

Players send heartbeats of (user, title, timestamp, position). Build the Continue Watching resume position for each user and title, using the newest heartbeat and resetting to zero once the viewer has passed 95 percent of the runtime.

Tubi
Coding & Algorithms
Software Engineer
Tubi
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

0

0 solved


Players send heartbeats of (user, title, timestamp, position). Build the Continue Watching resume position for each user and title, using the newest heartbeat and resetting to zero once the viewer has passed 95 percent of the runtime.

Continue Watching is a top homepage row on Tubi's TV apps, and it is fed by heartbeat telemetry from many device types with clock and ordering quirks. The interviewer wants a correct reduce-by-key, plus sensible handling of out-of-order and duplicate events.

What the Interviewer Expects
  • Keys by (user, title) and keeps the latest heartbeat by event timestamp, not arrival order
  • Defines a deterministic tie-break for equal timestamps
  • Applies the completion threshold and clamps positions to the runtime
  • Handles titles with unknown runtime without crashing
  • Gives O(n) time and O(unique pairs) space
Key Topics to Cover
Hash maps
Reduce by key
Event ordering
Telemetry
Continue Watching
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you make this incremental for a stream of heartbeats instead of a batch?
  • A user scrubs backward on purpose. Should the latest position still win? Why?
  • For a series, how would you decide to show the next episode instead of position zero?
  • How would you defend against devices with badly skewed clocks?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: an iterable of (user, title, ts, position_sec) and a dict of runtimes. Output: (user, title) -> resume seconds. Newest ts wins because a viewer may rewind; arrival order is unreliable on ...

High-Level Design

One pass to keep the newest heartbeat per key, then a second pass over the small map to apply clamping and the completion rule. Separating the two makes the reduce step reusable in a streaming job....


Submit Your Answer
Markdown supported

Related Questions