Domanda di colloquio di Yelp

Trasverse graph algorithm question for the first interview.