Given a directed graph, design an algorithm to find out whether there is a route between two nodes.
Example
Given graph:
1 | A----->B----->C |
No.1
Input:s = B and t = E,
Output:true
No.2
Input:s = D and t = C,
Output:false
Code
1 | public class DirectedGraphNode { |
1 | public boolean hasRoute(ArrayList<DirectedGraphNode> graph, DirectedGraphNode s, DirectedGraphNode t) { |