Fewest Pipeline Jobs to Trigger So Every Job Eventually Runs
Last updated: November 29, 2026
Quick Overview
A data pipeline has n jobs and directed edges [u, v] meaning job u triggers job v when it finishes. The graph is acyclic. Return the smallest set of jobs you must start manually so that every job eventually runs.
Meta
November 29, 20260
0
0 solved
A data pipeline has n jobs and directed edges [u, v] meaning job u triggers job v when it finishes. The graph is acyclic. Return the smallest set of jobs you must start manually so that every job eventually runs.
Shows up in Meta technical screens for data engineering candidates who work with warehouse DAG schedulers. The interviewer wants you to notice that in a DAG the answer is exactly the set of jobs with no incoming trigger, and to justify why that set is both necessary and sufficient.
What the Interviewer Expects
- Identify that only zero in-degree jobs are required
- Argue necessity (nothing else can trigger them) and sufficiency (every node in a DAG is reachable from a source)
- Avoid running BFS from every node
- Return results in a deterministic order
- Discuss what breaks if cycles are allowed
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How does the answer change if the trigger graph can contain cycles?
- If each manual start has a cost, how would you pick the cheapest set in a cyclic graph?
- How would you incrementally maintain the set as edges are added and removed?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input:
njobs labeled0..n-1and a list of trigger edges[u, v]. - The graph is a DAG (given).
- Output: the minimum set of jobs to start manually, sorted ascending....
High-Level Design
Two facts settle it:
- Necessity. A job with in-degree zero has no upstream trigger, so it must be started manually.
- Sufficiency. In a DAG, walk backwards from any job along incoming edge...