Algorithm · Google · Medium
You are given an undirected graph with no edge weights whose nodes are labeled 0 through n-1, along with a start node s and a destination node t. Answer two questions about this graph. First, determine the length (number of edges) of a shortest route from s to t. Second, collect every node that lies on at least one of the shortest routes between s and t, and list them in increasing order of node id. When no route from s to t exists, print -1 for the distance and print an…