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
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

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
Intervals
Sorting
Interval union
Watch-time metrics
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 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 Problems
Sample 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...


Submit Your Answer
Markdown supported