Pregunta de entrevista de Optiver

One question was a graph problem