ETL Pipeline Scheduler
Updated
Problem statement
An ETL pipeline contains uniquely named jobs and dependency edges. A dependency [before, after] means job before must finish before job after can run.
Return one valid execution order. Whenever several jobs are ready, choose the lexicographically smallest job identifier, so there is only one right answer. If the dependencies contain a cycle, return an empty array.
Function
scheduleEtlPipeline(jobIds: String[], dependencies: String[][]) → String[]Examples
Example 1
jobIds = ["extract","transform","load"]dependencies = [["extract","transform"],["transform","load"]]return = ["extract","transform","load"]Job extract has no prerequisite, so it goes first. Transform needs extract, and load needs transform. The order is extract, transform, load.
Example 2
jobIds = ["load_b","extract","load_a"]dependencies = [["extract","load_a"],["extract","load_b"]]return = ["extract","load_a","load_b"]Job extract goes first. After that, load_a and load_b are both ready. The name load_a comes before load_b, so load_a goes next.
Example 3
jobIds = ["a","b"]dependencies = [["a","b"],["b","a"]]return = []Job a must come before b, and b must come before a. That is a cycle, so no order works and the answer is an empty array.
Constraints
1 <= jobIds.length <= 20000.- Job identifiers are unique nonempty ASCII strings.
0 <= dependencies.length <= 50000; every edge contains two known, different identifiers and edges are distinct.
More Unity interview questions
Similar questions at other companies
- Course Schedule IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Lexicographically Smallest Topological OrderByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
- Merge Subsequences Into a Consistent Total OrderGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Topological Sort with Secondary OrderingRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
- Lexicographically Smallest Course OrderLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Microservice Deployment OrderGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Course Schedule IIWalmart · ONSITE INTERVIEWWalmart interview questions
- Task Order With PrerequisitesDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
- Course Schedule IIBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Task Order with Smallest Ready Task FirstExpedia · ONSITE INTERVIEWExpedia interview questions