Databricks interview question

Graph Problem, Solved using standard Graph algos.