Validate Subtitle Cue Timings in a WebVTT File

Last updated: November 29, 2026

Quick Overview

Given the timing lines of a WebVTT subtitle file, such as "00:01:02.500 --> 00:01:04.000 align:start", report every line that is malformed, has an end time not after its start time, or starts earlier than the previous cue.

Netflix
Coding & Algorithms
Software Engineer
Netflix
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given the timing lines of a WebVTT subtitle file, such as "00:01:02.500 --> 00:01:04.000 align:start", report every line that is malformed, has an end time not after its start time, or starts earlier than the previous cue.

Netflix localizes titles into dozens of languages and its timed text pipeline must reject broken subtitle files before they reach members. This parsing question checks careful string handling, support for the optional hours field, and producing actionable error messages rather than crashing on the first bad line.

What the Interviewer Expects
  • Parse both hh:mm:ss.mmm and mm:ss.mmm timestamp forms
  • Ignore cue settings after the end timestamp
  • Validate each line independently and collect all problems
  • Convert to integer milliseconds before comparing
  • Report line numbers so a localization vendor can fix the file
Key Topics to Cover
string parsing
regular expressions
validation
timestamps
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 detect overlapping cues that would display two subtitles at once?
  • How would you stream-validate a file too large to load in memory?
  • What extra rules would you enforce for reading speed (characters per 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 input line should look like start --> end [settings]. Timestamps are hh:mm:ss.mmm or mm:ss.mmm with minutes and seconds below 60 and exactly three millisecond digits. Report (line_number, p...

High-Level Design

Split on the arrow, parse the start, take the first whitespace token after the arrow as the end, and convert both to milliseconds with one anchored regex. Comparisons happen on integers. Lines that fa...


Submit Your Answer
Markdown supported