Fewest Moderator Check-ins That Cover Every Flagged Interval

Last updated: November 29, 2026

Quick Overview

A LIVE stream has flagged intervals `[start, end]` (in seconds) during which a moderator must look at the stream at least once. A single check-in at time t satisfies every interval containing t; return a minimum set of check-in times.

TikTok
Coding & Algorithms
Software Engineer
TikTok
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


A LIVE stream has flagged intervals `[start, end]` (in seconds) during which a moderator must look at the stream at least once. A single check-in at time t satisfies every interval containing t; return a minimum set of check-in times.

TikTok's LIVE safety tooling schedules human review against automated flags, and this greedy question checks whether you can find and prove the earliest-end-first rule. The interviewer wants a correct sort key, a tight explanation of why the greedy is optimal, and attention to closed versus open endpoints.

What the Interviewer Expects
  • Chooses to sort by end time and explains why sorting by start fails
  • Places each check-in at the end of the first uncovered interval
  • Exchange argument for optimality
  • Correct comparison for closed intervals that touch
  • Returns the actual times, not just the count
Key Topics to Cover
greedy
interval point cover
sorting
exchange argument
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
  • Moderators can only check in at multiples of 5 seconds; what changes?
  • Each check-in now covers a 10 second window instead of a point; how do you adapt the greedy?
  • Flags stream in live; can you place check-ins online, and how good is that?
  • How would you weight intervals by severity if moderators are limited?
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

Intervals are closed, so [1,4] and [4,6] can share a check-in at 4. Output a list of times of minimum size such that each interval contains one of them. n up to around 10^5....

High-Level Design

Sort by end time. Keep last, the most recent check-in. For each interval in order, if start <= last it is already covered. Otherwise place a new check-in at its end. Why the end? Among all points ...


Submit Your Answer
Markdown supported