Pregunta de entrevista de Optiver

Medium/hard leetcode graph search question