Publicis Sapient's Sapient Slingshot orchestration layer needs to run background jobs in parallel, but a job may start only after all of its dependencies finish. Implement a scheduler that simulates this multithreaded execution and returns the order in which jobs start.
A job is represented by an integer 0..n-1. You are given dependency pairs [a, b] meaning job b depends on job a, so a must complete before b can begin. At most worker_count jobs can run at the same time. When multiple jobs are ready, always start the smaller job id first. Each job takes exactly 1 time unit, and all jobs that start in the same time unit complete together at the end of that unit.
Return a list of lists, where each inner list contains the job ids started in one time unit. If all jobs cannot be completed because of a cycle, return an empty list.
n (int), dependencies (list of [int, int]), worker_count (int)list[list[int]]Example 1
n = 4, dependencies = [[0,2],[1,2],[2,3]], worker_count = 2[[0,1],[2],[3]]0 and 1 can start together. Then 2 becomes ready, then 3.Example 2
n = 3, dependencies = [[0,1],[1,2],[2,0]], worker_count = 2[]1 <= n <= 10^50 <= len(dependencies) <= 2 * 10^51 <= worker_count <= n0 <= a, b < n, and a != b