← Back
00:00

Parallel Task Scheduler

Goldman Sachs interview questions · Hard · Coding round · 6 tests

You are given n tasks, where task i takes durations[i] hours to complete. Some tasks depend on others, and a task may begin only after all of its prerequisites finish.

You also have workerCount identical workers. Whenever one or more workers are idle, the scheduler immediately starts as many ready tasks as possible, using these deterministic tie-breakers:

  1. pick the ready task with the smallest index first,
  2. if several workers are free at the same time, assign the next task to the smallest worker index.

Return the schedule timeline and the total completion time. If the dependency graph contains a cycle, return null.

Interface

Idle