Minimum Wall-Clock Time to Finish a Pipeline of Dependent Jobs
Last updated: November 29, 2026
Quick Overview
Each data pipeline job has a duration and a list of upstream jobs it waits on; with unlimited workers, return the minimum total time to finish every job, or -1 if the dependencies contain a cycle.
Uber
November 29, 20260
0
0 solved
Each data pipeline job has a duration and a list of upstream jobs it waits on; with unlimited workers, return the minimum total time to finish every job, or -1 if the dependencies contain a cycle.
Uber's data platform orchestrates large DAGs of batch jobs that feed pricing, finance and reporting. The onsite interviewer checks that you see the answer as the longest weighted path in a DAG and compute it in topological order rather than simulating time.
What the Interviewer Expects
- Recognize the critical path as the longest path in the DAG
- Compute earliest finish times in topological order
- Detect cycles via Kahn's processed count
- Handle jobs with no dependencies
- Discuss what changes with a limited worker pool
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
- Return the critical path itself
- What if only W workers are available? Is the problem still polynomial?
- Which job would you speed up first to reduce total time, and why?
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:
duration[i]for jobs0..n-1,deps[i]list of upstream job ids. - A job starts once all upstream jobs finish; unlimited parallelism.
- Output: max finish time across jobs, or -1 on a cyc...
High-Level Design
Let finish[j] = duration[j] + max(finish[u] for u in deps[j]), with max over an empty set equal to 0. This is DP over a DAG, so we evaluate jobs in topological order. Kahn's algorithm gives that ord...