# Longest Path in a Directed Acyclic Graph (DAG) — Interview Question

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/3434/find-longest-path-in-dag
Source observed: 2026-11-04T23:00:09.681Z
Last checked: 2026-11-04T23:00:09.681+00:00
Indexed: 2026-11-06T02:28:37.788+00:00

---

# Given a Directed Acyclic Graph (DAG), write a function to return the length of the longest path.

This Aced question is a data-structures-and-algorithms and coding-interview prompt. It asks you to write a function that returns the length of the longest path in a directed acyclic graph. The page does not include a community-submitted answer or an implementation.

## Question details

- **Reported last asked:** 3 months ago
- **Roles:** [Software Engineer](https://www.aced.io/questions?role=swe), [Site Reliability Engineer](https://www.aced.io/questions?role=sre), [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer)
- **Companies:** [Meta](https://www.aced.io/questions?company=meta-facebook), [Suno](https://www.aced.io/questions?company=suno)
- **Categories:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms), [Coding](https://www.aced.io/questions?type=coding)
- **Detailed company statistics:** available through [Upgrade](https://www.aced.io/upgrade?src=questions)

## Interview experiences

Two shared interview experiences are associated with this question:

1. **[Suno · 3 months ago](https://www.aced.io/experiences/suno-senior-software-engineer-interview-729c99)** — Software Engineer, Senior / L5
   > “Process was rigorous but enjoyable. Recruiters were a joy to work with, although final onsite was tough.”

2. **[Meta · 4 months ago](https://www.aced.io/experiences/meta-facebook-site-reliability-engineer-interview-129c6b)** — Site Reliability Engineer, Entry Level / L3
   > “Very rigorous. Interviewers were in a rush. I believe it’s crucial to get a feel of what you should expect during the interview and what kinds of signals you need to give. So I strongly recommend scheduling mock interviews with peers or, much more preferably, actual google or Facebook employees.”

## Community answers

No answers have been contributed by the community yet. To submit an answer, you must [log in or sign up](https://www.aced.io/signup?src=nav&returnPath=/questions/3434/find-longest-path-in-dag). Submitting marks the question complete.

## Related questions

- [Given an array of points on a plane (x,y), write a function to return the distance between the closest pair of points.](https://www.aced.io/questions/4630/closest-pair)
- [Write a function to return all prime numbers up to a given number n.](https://www.aced.io/questions/3629/prime-numbers)
- [Given the head of two singly linked lists, write a function to return the point where they intersect (if any).](https://www.aced.io/questions/4634/linked-lists-intersection)

## Related courses

### [Machine Learning Engineer Interview Prep](https://www.aced.io/courses/ml-engineer)

![Machine Learning Engineer Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/6UfkHxUyLQVfDHSfLNQtWa/1be1539a65b4f6f15201f5b573c0a578/ML_Engineer_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We cover mock interviews, frameworks, and advice from senior candidates for machine-learning roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies. Topics include ML system design, core concepts, coding, and behavioral interviews.

### [Software Engineering Interview Prep](https://www.aced.io/courses/software-engineering)

![Software Engineering Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/4VkuYewBHUFIVUS5oJDW5h/02e833439b1289f25f38f13f81cbdca3/adobe_stock_optimized.jpeg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for software-engineering roles at Google, Amazon, Microsoft, Meta, Apple, and other companies. The course covers data structures, algorithms, system design, people management, behavioral interviews, mock interviews, frameworks, and advice from senior candidates.

## Explore Aced

We are Aced, formerly Exponent. Our interview-preparation resources include:

- **Courses:** [all courses](https://www.aced.io/courses?src=nav), including [Product Management](https://www.aced.io/courses/pm?src=nav), [Forward Deployed](https://www.aced.io/courses/forward-deployed-engineering?src=nav), [Engineering Management](https://www.aced.io/courses/engineering-management?src=nav), [Software Engineering](https://www.aced.io/courses/software-engineering?src=nav), [System Design](https://www.aced.io/courses/system-design-interviews?src=nav), [Data Science](https://www.aced.io/courses/data-science?src=nav), [Machine Learning](https://www.aced.io/courses/ml-engineer?src=nav), [Data Engineering](https://www.aced.io/courses/data-engineering?src=nav), [AI Engineering](https://www.aced.io/courses/ai-engineering?src=nav), [Investment Banking](https://www.aced.io/ib?src=nav), [Generative AI](https://www.aced.io/courses/gen-ai-interviews?src=nav), [Security Engineer](https://www.aced.io/courses/security-engineer?src=nav), [TPM](https://www.aced.io/courses/tpm?src=nav), [Solutions Architect](https://www.aced.io/courses/solution-architect-interview?src=nav), [UX / Product Design](https://www.aced.io/courses/product-designer-interview?src=nav), and [BizOps & Strategy](https://www.aced.io/courses/bizops?src=nav).
- **Interview content:** [Loops](https://www.aced.io/guides?src=nav), [Experiences](https://www.aced.io/experiences?src=nav), [Questions](https://www.aced.io/questions?src=nav), and [Practice](https://www.aced.io/practice?src=nav).
- **Coaching:** [Mock Interviews & Coaching](https://www.aced.io/coaching?category=mock_interviews&src=nav), [Resume Review](https://www.aced.io/resume?src=nav), [Salary Negotiation](https://www.aced.io/coaching?category=negotiation&src=nav), and [How Coaching Works](https://www.aced.io/coaching/start?src=nav).
- **Additional services:** [Pricing](https://www.aced.io/upgrade?src=nav), [Job Referrals](https://www.aced.io/jobs/referrals?src=nav), [Blog](https://www.aced.io/blog?src=nav), [Resources](https://www.aced.io/resources?src=nav), [Perks](https://www.aced.io/perks?src=nav), [university programs](https://www.aced.io/pages/university?src=nav), [business services](https://www.aced.io/pages/business?src=nav), [recruiter job posting](https://www.aced.io/jobs/post?src=nav), and our [affiliate program](https://www.aced.io/affiliate?src=nav).

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3434%2Ffind-longest-path-in-dag&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3434%2Ffind-longest-path-in-dag). Opening a form does not execute a tool.