Pregunta de entrevista de Netflix

Graph based question involving traversal