Перейти к содержимому

Longest Path in a DAG | GFG POTD | 2 Approaches Explained

Coding practice

0:00 / 0:00

Longest Path in a DAG | GFG POTD | 2 Approaches Explained

39 просмотров · 2 мес. назад
Coding practice
88 подписчиков
39 просмотров · 2 мес. назад
n this video, we solve an interesting Weighted Directed Acyclic Graph (DAG) problem where we need to find the longest distance from a given source vertex to every other vertex. For every vertex, we need to determine the maximum possible distance from the source. If a vertex cannot be reached from the source, we return INT_MIN (which the driver displays as INF). 🧠 What we cover in this video ✅ Understand the problem and the longest-distance concept in a DAG ✅ Work through the graph and edge weights step-by-step ✅ Understand how to calculate the maximum distance for every vertex ✅ Complete solution with code implementation ✅ Handle unreachable vertices using INT_MIN ✅ Discuss the Topological Sort approach and why it works for DAGs ✅ Analyze the time and space complexity