DAG utility with add, validate and query
Build a small directed-acyclic-graph helper: add edges, reject ones that would create a cycle, and answer reachability or ordering queries over the graph. Reported on 1point3acres' Notion bank; reconstructed in our own words.
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.