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
Coding & Algorithms
Data Engineer
Meta
November 29, 2026
Data Engineer
Technical Screen
Coding & Algorithms
Easy

0

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
DAG
in-degree
source nodes
reachability
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample Answer
Requirements
  • Input: n jobs labeled 0..n-1 and 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:

  1. Necessity. A job with in-degree zero has no upstream trigger, so it must be started manually.
  2. Sufficiency. In a DAG, walk backwards from any job along incoming edge...

Submit Your Answer
Markdown supported