Pregunta de entrevista de TradingHub

Graph-based problem, as far as I can recall.