Earliest Finish Time for a Video Processing Job DAG
Last updated: November 29, 2026
Quick Overview
After upload, a video goes through processing tasks such as transcoding, thumbnail extraction, audio fingerprinting and safety review. Each task has a duration and a list of tasks it depends on; with unlimited parallel workers, return the earliest time all tasks finish and one critical path.
TikTok
November 29, 20260
0
0 solved
After upload, a video goes through processing tasks such as transcoding, thumbnail extraction, audio fingerprinting and safety review. Each task has a duration and a list of tasks it depends on; with unlimited parallel workers, return the earliest time all tasks finish and one critical path.
TikTok's upload pipeline fans out into many dependent jobs before a video can be published, and publish latency directly affects creator experience. In onsite coding, this question checks longest-path-in-a-DAG reasoning on top of topological order, plus whether you can explain the critical path to a product partner.
What the Interviewer Expects
- Identifies the problem as longest path in a DAG weighted by task durations
- Computes finish times in topological order
- Tracks a predecessor pointer to reconstruct the critical path
- Detects cycles and treats them as invalid input
- Explains that unlimited workers means only dependencies constrain time
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 does the answer change if you have only m workers?
- Which task would you speed up first to reduce publish latency, and why?
- How would you handle a task that sometimes fails and is retried?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input:
tasks: dict[str, tuple[int, list[str]]]mapping task to(duration, deps). - Output:
(total_time, critical_path); raise on a cycle. - Unlimited parallelism: a task starts as soon as all ...
High-Level Design
With infinite workers, finish[t] = duration[t] + max(finish[d] for d in deps), or just the duration if there are no deps. That recurrence must be evaluated in topological order. The overall answer i...