Total Unique Seconds of a Reel Watched Across Replays
Last updated: November 29, 2026
Quick Overview
Given a list of [start, end) second ranges a viewer watched in one Reel, including rewinds and replays that overlap, return the number of distinct seconds of the video they actually saw.
Meta
November 29, 20260
0
0 solved
Given a list of [start, end) second ranges a viewer watched in one Reel, including rewinds and replays that overlap, return the number of distinct seconds of the video they actually saw.
Reels watch-time metrics distinguish total play time from unique coverage, and this short problem in the style of a Meta technical screen tests interval union. The interviewer checks that you sort, merge on the fly, and avoid double counting without materializing a per-second array.
What the Interviewer Expects
- Clarifies half-open ranges so [0,5) and [5,8) do not double count
- Sorts by start and sweeps with a running current interval
- Avoids allocating an array the length of the video
- Handles empty input and zero-length ranges
- States O(n log n) complexity
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 also return the share of the video covered?
- If ranges arrive as a stream, how do you keep the running total?
- How would you find the most rewatched second?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Each range is [start, end) in seconds, possibly unsorted and overlapping. Return the length of their union. Ranges with start >= end contribute nothing. The video can be long (hours of Live replay...
High-Level Design
Sort ranges by start. Keep the current merged block [cs, ce). For each next range, if it starts at or before ce it extends the block; otherwise the block is finished, so add ce - cs to the total...