Pregunta de entrevista de Optiver

A graph problem like a leetcode one