Pregunta de entrevista de Uber

To solve a question on Graph