Question d’entretien chez Google

A tough programming question related directed graph