Longest Path | Dynamic Programming
Given a directed acyclic graph(DAG) compute the longest path that the graph contains. For the purposes of this question, a path is defined
by the edges and the input graph is in the form of a list of lists where the list at index i
in the array represents each of the connections
formed by node i
. The number of nodes is guaranteed to not exceed 100000
.
Example:
Input:
Output: 2
Try it yourself
Title
Script
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum
has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Contrary to popular belief, Lorem
Ipsum
is not simply random text.
1 >>> a = [1, 2, 3] 2 >>> a[-1] 3 3