Domanda di colloquio di Google

A tough programming question related directed graph