Parallel job DAG makespan
You have a dependency DAG of jobs and K identical workers. jobs is a list of [id, duration]; deps is a list of [a, b] meaning job a must finish before job b starts. A job becomes eligible the moment all its dependencies have completed. At each decision point, idle workers pick eligible jobs in ascending id order. Each worker runs one job to completion (non-preemptive). Return the overall makespan (the time the last job finishes). Assume the DAG is valid (no cycles) and ids are unique non-negative integers.
Implement
dag_makespan(jobs: list[list[int]], deps: list[list[int]], K: int) → intExamples
in
[[[1,3],[2,2],[3,4]],[[1,3],[2,3]],2]out7What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 30 min
solution.py
InputExpectedGot
[[[1,3],[2,2],[3,4]],[[1,3],[2,3]],2]7not run yetsample