
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 != bn = 4, dependencies = [[0,2],[1,2],[2,3]], worker_count = 2Output[[0,1],[2],[3]]WhyJobs 0 and 1 have no prerequisites and start first. After both complete, job 2 becomes ready, and after 2 completes, job 3 starts.n = 6, dependencies = [[0,3],[1,3],[1,4],[2,5]], worker_count = 2Output[[0,1],[2,3],[4,5]]WhyAt time 1, jobs 0 and 1 start. Then jobs 2 and 3 are the smallest ready jobs; after that, jobs 4 and 5 can start together.n = 3, dependencies = [[0,1],[1,2],[2,0]], worker_count = 2Output[]WhyEvery job depends on another in a cycle, so no job can become ready initially.1 <= n <= 10^50 <= len(dependencies) <= 2 * 10^51 <= worker_count <= n0 <= a, b < na != bdef synchronized_schedule(n, dependencies, worker_count):