FastPrepETL Pipeline Scheduler

ETL Pipeline Scheduler

Unity logoUnity● MediumFULLTIMEONSITE INTERVIEW
Learn

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 the answer is deterministic. 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"]

The dependencies force the conventional ETL order.

Example 2

jobIds = ["load_b","extract","load_a"]dependencies = [["extract","load_a"],["extract","load_b"]]return = ["extract","load_a","load_b"]

After extraction, both loads are ready and their identifiers determine the tie.

Example 3

jobIds = ["a","b"]dependencies = [["a","b"],["b","a"]]return = []

The cycle leaves no complete pipeline order.

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 problems

See Unity hiring insights
public String[] scheduleEtlPipeline(String[] jobIds, String[][] dependencies) {
    // Write your code here.
}
jobIds["extract","transform","load"]
dependencies[["extract","transform"],["transform","load"]]
expected["extract", "transform", "load"]
Checking account…