CTCI 4.2 check for a route between two node in a graph