Earliest Finish Time for Build Tasks With Durations and Prerequisites
Last updated: November 29, 2026
Quick Overview
Each of n build tasks has a duration, and prerequisite pairs [a, b] mean b cannot start until a finishes. With unlimited machines, return the earliest time all tasks are complete. The graph is acyclic.
Meta
November 29, 20260
0
0 solved
Each of n build tasks has a duration, and prerequisite pairs [a, b] mean b cannot start until a finishes. With unlimited machines, return the earliest time all tasks are complete. The graph is acyclic.
A Meta onsite problem framed around the monorepo build system, where wall clock time is set by the critical path, not total work. The interviewer checks that you compute earliest start times in topological order and can explain why the answer is the longest weighted path.
What the Interviewer Expects
- Propagate earliest finish times in topological order
- Take the max over prerequisites, not the sum
- Identify the answer as the critical path length
- Handle tasks with no prerequisites
- Optionally reconstruct the critical path
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 reconstruct the critical path itself?
- Which task, if made one second faster, would reduce total build time?
- How does the answer change with only m machines available?
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:
durations[i]for tasks0..n-1andprereqsas[a, b](a before b). - Unlimited parallelism, DAG guaranteed.
- Output: earliest time when every task is finished....
High-Level Design
Let finish[v] be the earliest time task v can complete. A task starts once its slowest prerequisite is done:
, with the max over an empty set ...