Pregunta de entrevista de Databricks

A problem that require to do BFS multiple times