Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 2192. All Ancestors of a Node in a Directed Acyclic Graph
Given a DAG with n nodes and directed edges, compute for each node the sorted list of all nodes that can reach it (its ancestors). This is essentially computing the transitive closure/reachability for every node, leveraging the DAG/topological ordering to do it efficiently within the n ≤ 1000 constraint.
Asked at:
Amazon
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Mid October, 2024
Amazon
Mid-level
Find the number of ancestors of a person and list ancestors from oldest to newest
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.