Pregunta de entrevista de Uber

One question on graphs and algorithm