Databricks interview question

Standard BFS Leetcode style question