A friend of mine had this question in recent G interview and I am not sure what'd be the best approach. Say we have the following "directed" graph:
The goal is to find the longest path we can have from "any" of nodes in the graph. For the above graph, the answer is C with length of 6.
I can solve this problem for a DAG but not sure how to solve this for a directed graph with cycle in O(n) time. Any idea?