Find the Event Sources That Trigger Every Downstream Lambda

Last updated: November 29, 2026

Quick Overview

In an event-driven pipeline, an edge (u, v) means function u can trigger function v. Return the smallest set of functions you must invoke directly so that every function eventually runs, given the trigger graph has no cycles.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


In an event-driven pipeline, an edge (u, v) means function u can trigger function v. Return the smallest set of functions you must invoke directly so that every function eventually runs, given the trigger graph has no cycles.

A short phone screen question in the style of Amazon's serverless products, where EventBridge rules and Lambda functions form a trigger DAG. It looks like a search problem, and the interviewer wants you to notice that in-degree alone answers it.

What the Interviewer Expects
  • Recognize that in a DAG every node is reachable from some zero in-degree node
  • Argue zero in-degree nodes must be in any valid answer
  • Compute in-degree in one pass
  • O(n + m) time, O(n) space
  • Discuss what breaks if cycles are allowed
Key Topics to Cover
in-degree
DAG
sources
graph reasoning
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 would you solve it if the graph can contain cycles?
  • How would you also return which functions each source eventually reaches?
  • What if invoking some functions has a cost and you want the cheapest set?
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 functions and directed trigger edges. The graph is acyclic. Output: the minimum set of functions to invoke manually so every function runs....

High-Level Design

Two facts give the answer without any traversal:

  1. A function with no incoming trigger can never run unless invoked directly, so it must be in the answer.
  2. In a DAG, walking backwards along incomi...

Submit Your Answer
Markdown supported