Pregunta de entrevista de Citadel Securities

Simple Bfs question that can be found on leetcode