If G= (V, E) is a directed graph with V = {1,2,...,n}, for all u in V, define L(u) to be the smallest integer v such that there is a path from u to v.
Write an O(V + E)-time and space algorithm that, given a directed graph G = (V,E), computes L(u) for all u in V