← 返回 twosigma 的题目列表Directed Acyclic Graph (DAG) Algorithm Problem
类型:online_judge
Given a Directed Acyclic Graph (DAG), determine if there is a path from node A to node B. The input includes three parts: the number of nodes, a list of edges, and the start and end nodes for the query.
Example Input:
5
[[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]]
0 4
Example Output:
Yes
Explanation: In this example, there is a path from node 0 to node 4, hence the output is Yes.
Example
Input
5
[[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]]
0 4