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
November 29, 20260
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
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 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 ProblemsSample 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...