Pregunta de entrevista de Yelp

Trasverse graph algorithm question for the first interview.