Parallel job DAG makespan

Write codeHard30 minDatabricks style

Your task

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.

Examples

dag_makespan(jobs: list[list[int]], deps: list[list[int]], K: int) -> int
Example 1
Inputdag_makespan([[1, 3], [2, 2], [3, 4]], [[1, 3], [2, 3]], 2)
Output7